Sub topic 14
Check the Design Against the Requirements
This chapter closes the process. You have a design, and now you test it. It assumes you have already written requirements, stated assumptions, estimated capacity, sketched an API and data model, drawn a high-level architecture, and picked storage and scaling approaches. You should also be able to read short Python snippets.
Why a review step exists
A design drifts while you build it. You add a cache to fix one concern, a queue to fix another, and a shard key to fix a third. Each choice is reasonable alone. Together they may no longer serve the requirements you wrote at the start.
The review is a structured comparison of the finished design against the original list. It has three goals:
- Find requirements that no component serves.
- Find components that serve no requirement.
- Find numbers that no longer hold.
Do the review before you declare the design done, and say out loud that you are doing it. In an interview or a design meeting, this is the moment that shows you can judge your own work.
Step 1: Build a traceability table
A traceability table has one row per requirement. For each row, name the component that satisfies it and the evidence that it does. "Evidence" means something you can point to: an API endpoint, an index, a calculation, or a stated trade-off.
Suppose your requirements were to create items, read an item by ID, list a user's items with pagination, keep reads under 200 ms at the 99th percentile, and not lose acknowledged writes.
| Requirement | Component that serves it | Evidence | Status |
|---|---|---|---|
| Create an item | `POST /v1/items`, write path to primary database | API sketch, write QPS fits one primary | Covered |
| Read an item by ID | `GET /v1/items/{item_id}`, cache then database | Primary key lookup, 90% cache hit assumption | Covered |
| List a user's items | `GET /v1/users/{owner_id}/items` with cursor | Index on `(owner_id, created_at)` | Covered |
| p99 read latency under 200 ms | Cache, read replicas | No latency budget written down | Gap |
| No loss of acknowledged writes | Synchronous replication to one replica | Replication mode not stated | Gap |
The last two rows show why the table is worth building. Non-functional requirements are the ones most likely to be left without an owner. A cache and some replicas feel like they should help latency, but until you write a budget for each hop, you cannot show that they do.
Do the same in the other direction. List each component on your diagram and ask which requirement justifies it. A component with no requirement is either unnecessary or points to a requirement you never wrote down. Both are worth knowing.
Step 2: Walk each functional requirement through the design
Pick one request and follow it from the client to storage and back. Say each hop aloud: load balancer, application server, cache, database. At each hop, ask what data it needs and where it gets it.
For "list a user's items," the walk might go like this:
- The client sends
GET /v1/users/user:42/items?limit=20&cursor=abc123. - The application server decodes the cursor into a position, for example the
created_atanditem_idof the last item the client saw. - The database runs an indexed range query on
owner_id, starting after that position, and returns 20 rows. - The server encodes the position of the last row as the next cursor.
If the walk stalls, you have found a defect. A common one is a query that needs data from a different shard than the one the request hit. If items are sharded by item_id but listed by owner_id, the list query touches every shard. Either change the shard key, add a secondary index, or accept the fan-out and state its cost.
Step 3: Re-run the numbers against the design
Capacity estimates are only useful if you compare them with what the design can actually handle. Write down the limit of each component, then check that the estimated load fits with headroom. Headroom is spare capacity kept for growth and spikes.
The script below reuses the assumptions from the estimation chapter and adds capacity limits for the architecture. The limits are assumptions you would replace with measured or vendor figures.
DAU = 10_000_000
WRITES_PER_USER_PER_DAY = 5
READS_PER_USER_PER_DAY = 100
RECORD_BYTES = 500
SECONDS_PER_DAY = 86_400
PEAK_FACTOR = 2
CACHE_HIT_RATIO = 0.9
COPIES = 3
PRIMARY_WRITE_LIMIT_QPS = 2_000
REPLICAS = 2
REPLICA_READ_LIMIT_QPS = 3_000
CLUSTER_DISK_GB = 36_000
peak_write_qps = DAU * WRITES_PER_USER_PER_DAY / SECONDS_PER_DAY * PEAK_FACTOR
peak_read_qps = DAU * READS_PER_USER_PER_DAY / SECONDS_PER_DAY * PEAK_FACTOR
db_read_qps = peak_read_qps * (1 - CACHE_HIT_RATIO)
storage_gb = DAU * WRITES_PER_USER_PER_DAY * RECORD_BYTES / 1e9 * 365 * COPIES
def check(name, need, have, headroom):
status = "PASS" if have >= need * headroom else "FAIL"
print(f"{status} {name}: need {need:,.0f}, have {have:,.0f} (headroom {headroom:.1f}x)")
check("primary write QPS", peak_write_qps, PRIMARY_WRITE_LIMIT_QPS, 1.5)
check("replica read QPS with cache", db_read_qps, REPLICAS * REPLICA_READ_LIMIT_QPS, 1.5)
check("storage, 1 year x 3 copies (GB)", storage_gb, CLUSTER_DISK_GB, 1.2)
check("replica read QPS if cache is down", peak_read_qps, REPLICAS * REPLICA_READ_LIMIT_QPS, 1.0)Running it prints:
PASS primary write QPS: need 1,157, have 2,000 (headroom 1.5x)
PASS replica read QPS with cache: need 2,315, have 6,000 (headroom 1.5x)
PASS storage, 1 year x 3 copies (GB): need 27,375, have 36,000 (headroom 1.2x)
FAIL replica read QPS if cache is down: need 23,148, have 6,000 (headroom 1.0x)The first three lines say the normal design holds. The fourth line is the useful one. It shows that the database tier survives only while the cache works. If the cache fails or is restarted empty, read load rises about tenfold and the replicas are overwhelmed. That is a real finding, and you can now respond to it with a concrete choice:
- Add replicas until the database can survive without the cache.
- Keep the cache in a replicated cluster so a single failure does not empty it.
- Add rate limiting and request coalescing, so many requests for the same missing key trigger one database read.
- Accept the risk and write it down.
Step 4: Test failure scenarios
Take each component in turn and ask what happens if it fails or slows down. Check the answer against the requirements. Four questions cover most of the ground:
- What does the user see? An error, stale data, or a slower response?
- Is acknowledged data still safe?
- Does the failure spread? A slow database can fill application-server threads, which then fail health checks.
- How does the system recover, and who or what triggers recovery?
Write the result as a short line per component, such as "Primary fails: promote a replica; writes pause for up to 30 s; acknowledged writes survive because replication is synchronous to one replica." If you cannot write that line, the requirement "no loss of acknowledged writes" is not yet met, and the traceability table should say so.
Common errors in a review
- Reviewing against the diagram instead of the requirements. A design can look tidy and still miss a requirement. Always start from the list.
- Checking only average load. Peaks, cache failures, and hot keys break systems, not averages.
- Treating non-functional requirements as automatically met. "Highly available" and "low latency" need a mechanism and a number.
- Hiding gaps. If something is unresolved, list it as an open risk. A stated gap is better than a gap the reader discovers.
- Restarting the whole design. A failed check usually points to one component. Fix that one and re-run only the checks it affects.
Step 5: Close with a short summary
End the review with a summary your audience can hold in their head. It has three parts:
- The requirements the design meets, with the key evidence for each.
- The assumptions that, if wrong, would change the design. For example, "if the cache hit ratio is below 70%, we need more replicas."
- The open risks and what you would do next, such as load-test the cache-down case or add a latency budget per hop.
This also sets up iteration. When a requirement changes later, you can find the affected rows in the table and re-run only those checks.
Exercise
Your design serves reads from a cache with a 95% hit ratio. Peak read load is 20,000 QPS, and two database replicas can each serve 3,000 QPS. (a) Does the design pass with 1.5x headroom when the cache works? (b) What does the review reveal about a cache outage, and name one mitigation.
Show answer
(a) Database reads are 20,000 x 0.05 = 1,000 QPS. Two replicas give 6,000 QPS, and 1,000 x 1.5 = 1,500 is below that, so it passes. (b) With the cache down, all 20,000 QPS reach the database, more than three times the 6,000 QPS capacity, so the check fails. Mitigations include adding replicas, running the cache as a replicated cluster, or coalescing requests for the same key and rate limiting so the database is not overwhelmed.
Exercise
A traceability table shows a component, a message queue, with no requirement pointing to it. What are two reasonable responses?
Show answer
Either remove the queue because nothing needs it, or find the missing requirement it serves, such as absorbing write bursts or decoupling a slow downstream step, and add that requirement to the list so the design and the requirements agree.