Lesson 13 of 28Writing that engineers read
Design Docs and RFCs
Write the design before the code: when a doc is worth it, the sections reviewers need, how the RFC process reaches a decision, and a worked example.
Your manager asks you to add rate limiting to the public API after one customer's script slowed it down for everyone. You know how token buckets work, so you start coding. Two weeks later, in code review, the platform team points out that the API gateway can already limit by key, security asks why API keys are stored in plain text in Redis, and the product manager wanted paying customers to get higher limits. Most of your code is now wrong, and all of these problems would have come up in a two-page document reviewed in two days. A design doc is how engineers find those problems while they are still cheap to fix. In many companies, writing good ones is also the clearest signal that you are ready for a senior role.
Why write before you build
A design doc is a short document that describes a problem, the solution you propose, and the trade-offs you considered, written before the main implementation starts. It does three jobs.
- It finds mistakes while they are cheap. Changing a paragraph costs minutes. Changing a schema after three services depend on it costs weeks. Reviewers catch missing requirements, existing tools you did not know about, and failure modes you did not think of.
- It aligns people. Product, security, the team that owns the system you touch and the people who will run it on call all read the same text. Disagreements surface before code exists, so nobody has to defend sunk work.
- It records the context. Six months later, someone asks "why Redis and not the gateway?" The doc answers, even if you have left the company.
Writing also forces you to think. Many engineers find their design falls apart in the "Alternatives considered" section, because writing down why option B is worse shows that it is not.
When a doc is worth it
A doc costs time to write and time to review, so do not write one for everything. Write one when the work is:
- Multi-week, so a wrong direction wastes real time.
- Cross-team, so other people must agree or change their plans.
- Hard to reverse: a public API shape, a data model, a new datastore, deleting data. In Evolutionary architecture and Conway's law you saw these called one-way doors.
- Risky: security, money, personal data, a migration of live traffic.
- Unclear: you cannot explain the approach in a ticket description, or two senior people already disagree.
Skip it for two-way doors that take a few days, for bug fixes, and when a one-day prototype would answer the question faster than a debate. A spike (time-boxed research) and a design doc work well together: build the spike to learn, then write the doc with what you learned.
Length should match the risk. A "mini design doc" of one to three pages is right for most features. Large systems may need ten or more pages. If your doc grows past that, split it: one overview doc and focused docs per part.
The anatomy of a design doc
Company templates differ, but the good ones all ask the same questions. Here is a template you can copy into your team's docs folder.
# <Title: what you are building, in plain words>
Status: Draft | In review | Approved | Rejected | Superseded | Implemented
Author(s): <names>
Reviewers: <names, and which part each one should check>
Approver: <one name: who decides>
Last updated: <YYYY-MM-DD>
Related: <tickets, ADRs, earlier docs>
## Summary
Three to five sentences. The problem, the proposal, and the main trade-off.
A busy reader who stops here should still know what you want to do.
## Context and problem
What exists today, what is wrong with it, and evidence (numbers, incidents,
customer reports). Link, do not repeat, background docs.
## Goals
Measurable outcomes. "p99 added latency under 2 ms", not "fast".
## Non-goals
Things a reasonable reader might expect, that this design will NOT do.
## Proposal
How it works. A diagram, the API or interface changes, the data model,
and what happens on failure. Enough detail that another engineer could
build it.
## Alternatives considered
Each real option, including "do nothing", with why it lost.
## Risks and open questions
What could go wrong, what you do not know yet, and how you will find out.
## Security and privacy
New data stored, who can access it, new attack surface, threat model link.
## Rollout and migration
Steps, feature flags, how to roll back, who is told and when.
## Testing and monitoring
How you will know it works before release, and in production.
## Decision log
Date, decision, who decided. Filled in during review.A few sections deserve more than the template can say.
Non-goals are the most underrated section. They are not "things that are bad". They are things a reader could reasonably expect, which you are choosing not to do. "Per-endpoint cost weighting is out of scope" stops a reviewer from asking for it, and stops the project from growing during implementation. If you cannot think of a non-goal, your scope is probably fuzzy.
Alternatives considered must contain real options, argued fairly. A doc with two obviously bad straw men next to your favourite tells reviewers you made the decision first and wrote the doc second. Always include "do nothing", with its cost. Sometimes it wins.
Rollout is where reviewers from operations look first. "Deploy it" is not a plan. Say what is behind a flag, what you will watch, what triggers a rollback, and whether rolling back is even possible once data has been written in a new format.
Security and privacy has its own heading so that it cannot be forgotten. Even "no new data stored, no new endpoints" is a useful answer, because it is now a claim someone can check.
Writing for skimmers
Most reviewers will read your summary, look at the diagram, and jump to the one section they care about. The approver reads the summary and alternatives. Security reads the security section. The on-call lead reads rollout. Write for that.
- Summary first. It carries the whole proposal in miniature. Rewrite it last, when you know what the doc says.
- Decisions in bold. "We will store buckets in the existing Redis cluster." A skimmer should find every decision by scanning for bold text.
- Numbers over adjectives. "Peak 1,200 requests per second" can be checked. "High traffic" cannot.
- Diagrams over paragraphs for anything with more than two moving parts. A box-and-arrow sketch is enough; the diagramming habits from What is system design apply here too.
- Short sections with descriptive headings, so the table of contents reads like an outline of the argument.
- Separate facts from opinions. "Redis p99 is 0.4 ms in our dashboards" is a fact. "Redis is the best fit" is your conclusion, and it needs the facts next to it.
The RFC process
RFC means "Request for Comments". The name comes from the documents that defined the internet protocols, starting with RFC 1 in 1969. Many companies use "RFC" and "design doc" for the same thing. Where they differ, an RFC is usually the process: a doc sent to a wider audience with a clear way to reach a decision. Open source projects run this in public: Rust has its RFC repository, Python has PEPs, and Kubernetes has KEPs. Reading a few accepted ones is excellent practice.
Write a rough draft and show it to one trusted peer first. Fixing the obvious holes before wide review saves everyone time.
Three rules make the process work.
Name the approver. One person, usually a tech lead, staff engineer or architecture group, decides. Reviewers advise. "Everyone must approve" means anyone can block forever.
Set a deadline. "Comments by Thursday, decision Friday." Silence by the deadline is not automatic approval, but it does let the approver decide without waiting for people who never read it.
Keep the status honest. A doc marked "Draft" for eight months, describing a system that shipped differently, misleads everyone who finds it. When you finish, mark it "Implemented" and note what changed, or "Superseded" with a link.
Handling feedback
Comments are the point of the exercise, so treat them as data, not attacks. The receiving side of this is the same skill as in Receiving feedback without the ego.
- Close every thread. Each comment ends as one of: changed the doc, answered and resolved, or moved to "Open questions" with an owner. An unresolved thread is a decision someone will reopen later.
- Update the doc, not just the thread. If your reply explains something, the doc was unclear. Fix the text so the next reader does not ask again.
- Ask reviewers to mark blocking comments. "Blocking: this loses data on failover" is different from "nit: rename this field". Without labels, authors treat all feedback as equal.
- Move long threads to a call. After three rounds of replies, talk for fifteen minutes, then write the outcome back into the doc.
- Disagree and commit. When the approver decides against your view, say so once, clearly, with reasons, ask for your dissent to be noted in the decision log, then help the chosen option succeed. Re-arguing in every later meeting costs trust you will need.
A worked example: rate limiting the public API
Here is the mini design doc for the scenario at the start, at the length most features need. Read it once as a reviewer would, then read the notes after it.
# Per-key rate limiting for the public API
Status: Approved (2026-09-19)
Author: Priya Shah Reviewers: Tom (platform), Ana (security), Lee (SRE)
Approver: Marco (API tech lead)
Related: INC-412, PROD-88, ADR-0021
## Summary
One API key sent 900 req/s on 3 Sep and pushed p95 latency for all
customers from 120 ms to 2.4 s (INC-412). **We will add a token-bucket
limit per API key, stored in our existing Redis cluster, returning 429
with Retry-After.** Limits depend on plan. Main trade-off: a Redis
dependency on every request, mitigated by failing open.
## Context and problem
- Public API: 41 customers, peak 1,200 req/s total, top key 140 req/s.
- No per-key limit exists. The CDN blocks floods by IP only, and this
customer's traffic came from 6 normal-looking IPs.
- Support has seen 3 smaller slowdowns from single keys this quarter.
## Goals
- One key cannot raise p95 latency for other keys by more than 10%.
- Free: burst 20, then 10 req/s. Pro: burst 100, then 50 req/s.
Limits changeable per key without a deploy.
- Added latency: p99 under 2 ms.
- Clients get 429 with Retry-After, so well-behaved SDKs back off.
## Non-goals
- DDoS protection (the CDN and WAF own this).
- Different costs per endpoint (later, if usage data shows a need).
- Usage-based billing.
- Limiting internal service-to-service traffic.
## Proposal
Middleware in the API service checks a token bucket before routing.
- Key: `rl:{sha256(api_key)}`. The raw key never reaches Redis.
- **Bucket state lives in Redis**, updated by one Lua script so the
read-refill-take step is atomic across our 8 API pods.
- Limits come from the plans table, cached for 60 s per pod.
- Responses carry Retry-After on 429, plus the IETF RateLimit header
fields (still an Internet-Draft; we will track the final version).
- **If Redis is unreachable we fail open**: allow the request, count
it in `ratelimit_redis_errors_total`, and alert after 1 minute.
client -> CDN -> API pod [rate-limit middleware] -> handlers
|
Redis (existing cluster, 0.4 ms p99)
## Alternatives considered
1. Gateway usage plans. Tom confirmed our gateway supports per-key
limits, but our keys are validated in the app, not the gateway.
Moving auth is a 6-week project. Rejected for now; revisit with
the gateway migration in Q2 (noted in open questions).
2. Fixed window counter (N requests per minute). Simpler, but allows
2N at a window boundary, which is the burst we need to stop.
3. Sliding window log. Exact, but stores one entry per request:
about 50x the memory of a bucket at our traffic.
4. In-memory buckets per pod. No Redis call, but 8 pods means each
key effectively gets 8x its limit, and it changes as we scale.
5. Do nothing; contact customers. This is what we did for INC-412.
It took 40 minutes, during which every customer was affected.
## Risks and open questions
- Risk: a limit too low breaks a real customer. Mitigation: shadow mode.
- Open: should the gateway own this after the Q2 migration? Owner: Tom.
## Security and privacy
Only hashed keys are stored. No new endpoints. Rejected requests are
still logged with key id for abuse investigation (30-day retention).
## Rollout and migration
1. Ship behind flag `rate_limit_mode` = off | shadow | enforce.
2. Shadow for 7 days: log would-be 429s, check no paying key hits them.
3. Email customers 14 days before enforcement, with SDK guidance.
4. Enforce for Free, then Pro a week later. Rollback: set flag to off.
## Testing and monitoring
Unit tests for the bucket maths; a load test with one key at 900 req/s
while others measure latency. Dashboards: 429s per key, Redis errors.
## Decision log
- 2026-09-17 Review: Ana asked for hashed keys (done).
- 2026-09-19 Approved by Marco. Gateway option deferred to Q2.Notice what makes it work:
- The summary alone tells the approver what, why and the main risk. The decisions are in bold.
- The context has numbers. "Top key 140 req/s" tells a reviewer that a 50 req/s Pro limit might be too low for someone, which is why shadow mode exists.
- The non-goals stop three predictable scope arguments before they start.
- The alternatives are real and fair. Option 1 was a good idea that lost on timing, and the doc says when to look at it again.
- Failure behaviour (fail open) is a decision, stated plainly, with its cost. Some systems should fail closed instead; the point is to choose on purpose.
- The decision log shows how review changed the design.
Docs with numbers in them invite checking. Before sending this one, the author simulated the limits against the incident traffic. You can do the same:
Press Run (⌘ Enter) to see what happens.The normal client loses nothing, even with its burst. The runaway script is cut to roughly its refill rate plus the initial burst. Try changing the Pro limits to 20, 10 and watch the normal client start getting rejected: that is the kind of finding you want before review, not after launch.
What does this print?
tokens, last = 5.0, 0.0 # capacity 5, refill 1 token per second
allowed = 0
for t in [0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2]:
tokens = min(5, tokens + (t - last) * 1)
last = t
if tokens >= 1:
tokens -= 1
allowed += 1
print(allowed)How design docs go wrong
- The justification doc. Written after the code, to get a rubber stamp. Reviewers can tell, because the alternatives are weak and nothing in review changes the design. If the decision is already made, write an ADR instead and be honest about it.
- The novel. Twenty pages for a two-week feature. Nobody reads past page three, so the important risk on page eleven is never reviewed.
- No decision-maker. Comments pile up, everyone has an opinion, nothing is decided. Name the approver on line one.
- Design by committee. Every reviewer's suggestion is added, and the result does everything badly. Part of the author's job is to say "good idea, out of scope" and add it to non-goals.
- The stale doc. Design docs describe a plan at a point in time. Do not try to keep them in sync with the code forever. Mark the status, record lasting decisions as ADRs, and keep living documentation in the repo, as covered in READMEs and docs people use.
Match each reviewer question to the section that should answer it.
Put the steps of a healthy RFC process in order.
- Tap the steps below in the right order.
- design doc
- A short document written before building that states a problem, a proposed solution, the alternatives and the trade-offs, so others can review it.
- RFC
- Request for Comments: a design doc sent for wide review with a defined process and a named decision-maker.
- non-goal
- Something a reader might expect the project to do that it explicitly will not, written down to control scope.
- alternatives considered
- The section listing each real option, including doing nothing, and why it lost.
- approver
- The one named person or group who makes the final decision on a design doc.
- disagree and commit
- Stating your objection clearly once, then fully supporting the decision that was made.
- shadow mode
- Running new logic in production without acting on its result, only logging what it would have done.