Section 6: Five Boxes and a Confession - High-Level Architecture
Executive Summary: This section assembles the baseline architecture: five components, one transaction, no queue, no stream, no second region. We defend every absence with a number from the workload analysis, walk the write and read paths end to end, and — the Staff move — name the precise threshold at which this honest, boring design stops being correct. The architecture here is restraint made visible: a design sized for the median post that admits, in a single sentence, exactly where the celebrity post will break it.
The interviewer hands you the marker: "Okay — draw it." This is the moment the two failure archetypes diverge for good. The Dismissal draws two boxes and an UPDATE statement and considers the matter closed. The Citadel draws eleven boxes, three of which say "Kafka," for a feature whose median post will collect perhaps a dozen likes in its lifetime. You are going to draw five boxes, defend why there isn't a sixth, and then do the thing neither archetype can: write down the number at which your own drawing becomes wrong.
Key Insight: At Staff level, the architecture diagram is scored twice — once for what's on it, and once for what isn't. Every absent component you can defend with a measured number is worth more than a present component you can't. Restraint is the architecture.
The Five Boxes
Each box earns its place by doing a job the requirements demand, and nothing more:
| Component | Job | The number that sizes it |
|---|---|---|
| Client | Optimistic UI: fill the heart instantly, reconcile later | Perceived like-latency ~0 regardless of the p99 ≤ 150ms ack budget |
| API gateway | Verify the received identity, validate the request, route | Sits on every one of ~350K reads/s and ~35K writes/s at peak |
| Like service | Owns the semantics: the state-setting PUT/DELETE from Section 4, the atomic conditional write below | Stateless; scales horizontally with the ~11.6K writes/s average |
| KV store | The likes ledger (post_id, user_id) plus the co-located counter row — Section 5's model, verbatim |
1B write actions/day; partitioned so no node sees more than its share |
| Redis count cache | post_id → count, serving the render hot path |
~25GB holds every count that will be read today — one modest cluster absorbing ~350K reads/s peak |
That's the whole system. Now defend the empty space around it.
Sign in to continue reading
The rest of this lesson is available with a free account. Signing in with Google or Microsoft is free.
Sign in to read the full lesson