两道书面题:延迟传播与生产配置The two written questions: how delay spreads, and production configuration
写代码的题有测试兜底,这两道题只有你自己。给你一套可复用的答题结构。The coding tasks have tests to fall back on. These two questions have only you. Here is an answer structure you can reuse.
这一页有什么On this page9
- 01 先说答题结构Start with the answer structure
- 02 第 1 题 · 题面与要点拆解Question 1 · the text, broken into the points it asks for
- 03 第 1 题 · 一份可以照着写的答案Question 1 · an answer you can follow
- 04 第 2 题 · 题面与那段配置Question 2 · the text and the configuration block
- 05 第 2 题 · 找问题的清单Question 2 · a checklist for finding the problems
- 06 第 2 题 · 一份可以照着写的答案Question 2 · an answer you can follow
- 07 写这两道题时的几条实操建议A few practical tips for writing these two answers
- 练习 · 动手做Practice
- 迁移模式Transfer
- 解释联邦图里某个 subgraph 高延迟为什么会拖慢整体Explain why one slow subgraph in a federated graph slows the whole request down
- 说出至少一种缓存策略,并说清它的失效策略和代价Name at least one caching strategy, and state how it is invalidated and what it costs
- 从一段 application.properties 里指出三个以上生产隐患Point out three or more production risks in a block of application.properties
- 掌握一个「风险 → 后果 → 修正 → 理由」的答题结构Learn one answer structure: risk, then consequence, then fix, then reason
这两道题占的分不小,而且完全没有测试。很多人在这里写两句话就交了 —— 而它恰恰是最容易通过「结构化表达」拿分的地方。These two questions are worth real points, and no test checks them. Many people write two sentences and submit. This is the easiest place in the exam to earn points just by organising what you say.
graphql-federation-practice/QUESTIONS.md两道题的原文The two questions as written
提醒:源项目在磁盘上是做完的版本 —— 下面就是答案。想自己先写一遍的话,现在关上。Heads up: on disk this project is the finished version — what follows is the answer. Close this if you want to write it yourself first.
graphql-federation-practice/QUESTIONS.mdgraphql-federation-practice/java-service/src/main/resources/application.properties项目里真实的配置(和题面给的片段不完全一样)The real configuration in the project, which is not quite the snippet in the question
graphql-federation-practice/java-service/src/main/resources/application.properties先说答题结构Start with the answer structure
这两道题都能套同一个模板。The same template fits both questions.
书面题的评分点通常是「有没有覆盖到关键面」, 而不是文采。所以用固定结构写,最不容易漏:
| 段 | 写什么 |
|---|---|
| 结论先行 | 一句话给出核心判断,别铺垫 |
| 机制 | 为什么会这样 —— 讲清因果链,不只是现象 |
| 方案 | 具体做什么,最好带上配置或代码 |
| 代价与边界 | 这个方案的代价是什么、什么时候不适用 —— 这一段最能区分水平 |
最后那一段是关键。只说方案的人像是背过; 能说出代价的人像是用过。
Written questions are usually scored on whether you covered the key angles, not on prose. So write to a fixed structure and you are least likely to miss one:
| Section | What goes in it |
|---|---|
| Verdict first | One sentence with the core judgement. No warm-up. |
| Mechanism | Why it happens — spell out the causal chain, not just the symptom |
| Fix | Exactly what to do, ideally with config or code |
| Cost and limits | What the fix costs, when it does not apply — this section separates the levels |
That last section is the one that counts. Someone who only lists the fix sounds memorised; someone who can name the cost sounds like they have shipped it.
第 1 题 · 题面与要点拆解Question 1 · the text, broken into the points it asks for
原文:
题目要求两件事:① 解释影响(对依赖它的 subgraph)、② 给一种缓存策略缓解性能问题。
注意题面用的词是 dependent subgraphs。 这里有个需要说清的细节:subgraph 之间通常并不直接互相调用—— 它们都由 Router 编排。所以「影响」的准确传导路径是:
能把这条路径说清楚,这道题就答对了一半。
The original text:
The question asks for two things: ① explain the impact on the subgraphs that depend on it, and ② give one caching strategy to take the edge off the performance hit.
Note the wording: dependent subgraphs. There is a detail worth spelling out here — subgraphs normally do not call each other directly. The Router orchestrates all of them. So the accurate path the impact travels is:
Explain that path clearly and you are already halfway to a full answer.
graphql-federation-practice/QUESTIONS.md第 1 题 · 一份可以照着写的答案Question 1 · an answer you can follow
这是 DrillLab 写的参考答案,不是官方标准答案。This is a reference answer written by DrillLab, not an official one.
下面这份按「结论 → 机制 → 方案 → 代价」写。标为 DrillLab 自出—— 原项目的 QUESTIONS.md 里答案区是空的 ([Write answer here]), 没有官方答案可对照。
The answer below follows verdict → mechanism → fix → cost. It is marked as written by DrillLab: the answer area in the original QUESTIONS.md is empty ([Write answer here]), so there is no official answer to compare against.
第 2 题 · 题面与那段配置Question 2 · the text and the configuration block
题目给了一段部署到 AWS EKS 的application.properties, 要求指出至少三个生产/安全问题, 每个都说明风险并给出修正配置与理由。
注意题面给的片段和项目里真实的文件不一样。项目里那个只有三行:
题面给的片段多了数据源和口令占位符。答题时以题面为准。但注意项目真实文件里那行management.endpoints.web.exposure.include=*是两边都有的 —— 这是最明显的问题。
The question hands you an application.properties destined for AWS EKS and asks you to name at least three production or security problems, each with the risk, a corrected config, and the reasoning.
Careful: the snippet in the question is not the same as the real file in the project. The real one is three lines long:
The snippet in the question adds a datasource and password placeholders. Answer against the question, not the repo. But notice that the line management.endpoints.web.exposure.include=* appears in both — that is the most obvious problem of the lot.
graphql-federation-practice/QUESTIONS.mdgraphql-federation-practice/java-service/src/main/resources/application.properties第 2 题 · 找问题的清单Question 2 · a checklist for finding the problems
按这几个面扫一遍,三个问题很容易凑够,而且不会漏掉重要的。Scan these areas in turn. Three problems are easy to reach, and you will not miss the important ones.
- 暴露面。哪些端点被公开了? actuator 全开是最典型的问题。
- 凭据管理。口令从哪来? 环境变量算及格,但不算好。
- 传输安全。有 TLS 吗? 数据库连接加密了吗?
- 资源与韧性。连接池、超时、重试、 优雅停机 —— 一个都没配。
- 可观测性。健康检查分不分 liveness / readiness? 日志格式适合采集吗?
- 配置管理本身。所有环境共用一个 properties 文件? 没有 profile 隔离?
题目只要三个,但列五六个更好—— 只要每个都写清「风险 → 修正 → 理由」, 不会因为写多而扣分。
- Exposure. Which endpoints are public? Actuator wide open is the classic one.
- Credentials. Where does the password come from? An environment variable is a pass, not a good grade.
- Transport security. Is there TLS? Is the database connection encrypted?
- Resources and resilience. Connection pool, timeouts, retries, graceful shutdown — not one of them is configured.
- Observability. Does the health check split liveness from readiness? Is the log format fit for collection?
- Config management itself. One properties file for every environment? No profile separation?
The question asks for three, but five or six is better — as long as each one spells out risk → fix → reasoning, nobody deducts points for writing more.
第 2 题 · 一份可以照着写的答案Question 2 · an answer you can follow
同样按结构写,每个问题一小节。 下面列了六个,前三个是最该写的。
Same structure again, one short section per problem. Six are listed below; the first three are the ones you really must write.
写这两道题时的几条实操建议A few practical tips for writing these two answers
- 给出可以粘贴的配置。「应该限制 actuator 暴露」和
management.endpoints.web.exposure.include=health,info是两个水平。 - 按严重性排序。把 actuator 全开放在第一个 —— 它是唯一能直接 导致口令泄漏的。评分的人可能只认真看前两条。
- 承认某些「问题」其实是合理设计。
server.address=0.0.0.0在容器里是必须的(不然 Pod 外面连不上)。 把它当成安全问题反而暴露了对容器网络的不理解。能指出「这一条不是问题」是加分的。 - 每条都写「理由」。题目原文明确要求 with justification。 只给配置不给理由会丢分。
- 别写空话。「要遵循最佳实践」「要加强安全意识」这类句子零分, 而且会稀释真正有内容的部分。
- Give config someone can paste. “Actuator exposure should be restricted” and
management.endpoints.web.exposure.include=health,infoare two different grades. - Order by severity. Put actuator wide open first — it is the only one that leaks the password outright. Whoever grades this may only read the first two carefully.
- Admit when a “problem” is actually sound design.
server.address=0.0.0.0is required inside a container — without it nothing outside the Pod can connect. Calling it a security issue advertises that you do not understand container networking. Pointing out “this one is not a problem” earns credit. - Give reasoning for every item. The question says with justification in so many words. Config with no reasoning loses marks.
- No filler. Sentences like “follow best practices” and “improve security awareness” score zero, and they dilute the parts that have substance.
动手做Get your hands on it
填空只是过渡。真正掌握的标准,是在没有答案的时候从头写出来 —— 所以做完 L2 之后一定要往 L3、L4 走。Filling blanks is a stepping stone. The real bar is writing it from nothing, so once L2 is comfortable, push on to L3 and L4.
题面给的六行配置里,哪一行能直接导致数据库口令泄漏?
Of the six configuration lines in the question, which one can directly leak the database password?
graphql-federation-practice/QUESTIONS.md客户端查 { user(id:"1") { name orders { id } } }。 Accounts subgraph 要 500ms,Orders subgraph 只要 10ms。 总延迟大约是多少,为什么?
A client asks for { user(id:"1") { name orders { id } } }. The Accounts subgraph takes 500ms, the Orders subgraph only 10ms. Roughly what is the total latency, and why?
针对 management.endpoints.web.exposure.include=*, 写出修正后的配置。至少要做到:白名单、管理端口分离、 health 不泄漏细节、支持 k8s 探针。
Write the corrected configuration for management.endpoints.web.exposure.include=*. At a minimum: an allow list, management on its own port, a health endpoint that leaks no detail, and support for Kubernetes probes.
- 用白名单列出需要的端点,不用 *List the endpoints you need in an allow list; do not use *
- management.server.port 设成与业务端口不同的值Set management.server.port to something other than the business port
- health 端点不显示详情The health endpoint shows no details
- 开启 health probes(liveness / readiness)Turn on the health probes (liveness and readiness)
看答案之前,先确认你已经自己动手写过一遍。看懂别人的答案和自己写出来,是两种能力。Before you open this, make sure you have written it yourself once. Following someone else's answer and producing your own are two different skills.
换一道题也能用Works on other problems too
考试不会原题重考。真正能带走的是「看到这种信号 → 伸手去拿这个解法」。The exam will not reuse the same question. What you take away is the reflex: see this signal, reach for that solution.
- 答题结构:结论 → 机制 → 方案 → 代价与边界。最后一段最能区分水平。Answer structure: conclusion, then mechanism, then solution, then cost and limits. The last part separates good answers from average ones.
- 第 1 题的核心是「Router 的查询计划里 @key 那一步是前置依赖,所以串行」。The core of Question 1: in the Router query plan the @key step must finish first, so the calls run one after another.
- 缓存答案要包含四件事:缓存键、TTL、主动失效、一致性代价。A caching answer needs four things: the cache key, the TTL, active invalidation, and the consistency cost.
- 第 2 题按六个面扫:暴露面 / 凭据 / 传输 / 资源韧性 / 可观测性 / 配置管理。For Question 2, scan six areas: what is exposed, credentials, transport, resource resilience, observability, config management.
- actuator 全开是最严重的(/actuator/env 直接泄漏口令);server.address=0.0.0.0 在容器里不是问题。Leaving all of actuator open is the worst problem, because /actuator/env prints the password. server.address=0.0.0.0 is not a problem inside a container.