Sub topic 14
Check the design against the requirements
This chapter assumes you have already written down requirements and assumptions, estimated capacity, and drawn a high-level design with storage, scaling, and failure handling. The review is the last step. You go back to the start and test whether the design does what you said it would do.
Why a review pass matters
During design you make many small decisions, and requirements drift out of view. A cache gets added and nobody checks it against the freshness requirement. A queue gets added and nobody checks it against the latency target. A short review catches these gaps while they are cheap to fix.
Review in this order:
- Functional requirements.
- Non-functional requirements.
- Capacity numbers.
- Failure modes.
- Assumptions.
Trace each functional requirement
Take every functional requirement and walk it through the design. Name the API call, the service that handles it, and the data it reads or writes. If you cannot name all three, the design has a gap.
Suppose the requirements are "create an item" and "list a user's items". The trace looks like this:
| Requirement | API call | Component | Data touched |
|---|---|---|---|
| Create an item | `POST /v1/items` | Item service | Items table, written by `item_id` |
| List a user's items | `GET /v1/users/{owner_id}/items` | Item service | Items index by `owner_id` |
The second row exposes a common error. If the Items table is keyed only by item_id, listing by owner means a full scan. Fix it by adding an index or a second table keyed by owner_id.
Test each non-functional requirement
A non-functional requirement is only checkable if it has a number. "Fast" cannot be checked. "p99 read latency under 200 ms" can. For each target, point to the mechanism that meets it:
- Latency: a cache in front of the database, or a read replica near the user.
- Availability: replicas in more than one zone, and no single point of failure.
- Durability: replicated writes, plus backups you have actually restored.
- Consistency: the read path matches what you promised. A replica read after a write may return stale data.
Re-run the numbers
Compare your capacity estimate with what the chosen components can handle. The check below uses the peak write rate from the estimation chapter and an assumed limit per database node.
import math
PEAK_WRITE_QPS = 1158 # from the capacity estimate
NODE_WRITE_LIMIT_QPS = 1000 # assumed safe limit for one node
HEADROOM = 0.7 # plan to use at most 70% of the limit
usable_per_node = NODE_WRITE_LIMIT_QPS * HEADROOM
nodes_needed = math.ceil(PEAK_WRITE_QPS / usable_per_node)
print(f"usable writes per node: {usable_per_node:.0f}")
print(f"write nodes needed: {nodes_needed}")The output is 700 usable writes per node and 2 nodes needed. A single database fails this check, so the design needs partitioning, or you need to state that it is acceptable. Run the same check for reads, storage, and bandwidth.
Walk the failure modes
For each component on the request path, ask what happens when it is slow or down. Write one line for each: the impact, and the mitigation. If a component has no mitigation, either add one or list it as an accepted risk.
Audit your assumptions
Revisit the assumptions you wrote down early. Mark the ones the design depends on most, such as the read-to-write ratio. Say what would change if they were wrong. If reads were ten times higher, the cache layer would carry more load, and you would need to plan for that.
Close the review
End by stating three things: what the design satisfies, what it deliberately does not, and the main risks. Naming the limits is part of a good answer. It shows the trade-offs were chosen on purpose.
Exercise
A design has a cache in front of a database, and a requirement says users must see their own new post immediately after publishing. The cache entry for a user's feed expires after 60 seconds. Does the design pass the review? What would you change?
Show answer
It fails. A user who posts could read a cached feed that does not include the new post for up to 60 seconds. Either invalidate or update the user's feed cache entry on write, or read the user's own posts directly from the database. Then re-check latency, since the second option puts more load on the database.