Sub topic 7
Draw the high-level architecture
This chapter assumes you have a short list of requirements, rough capacity numbers, a sketched API, and a data model. You also need to know the common building blocks: load balancers, caches, queues, and databases. The high-level design connects these pieces into one picture that shows how a request travels through the system.
What the diagram must show
A high-level diagram is a small set of boxes and arrows. It is not a deployment plan. It should answer three questions:
- Where does each request enter, and which component handles it?
- Where does data live, and who is allowed to change it?
- Which work happens during the request, and which work can happen afterward?
Aim for five to ten boxes. If you need more, you are probably drawing a deep dive too early.
Build it from the API inward
Start with the API you already sketched. Each operation becomes a path through the system.
POST /v1/items
Content-Type: application/json
{"owner_id": "user:42", "body": "hello"}
GET /v1/items/{item_id}
GET /v1/users/{owner_id}/items?limit=20&cursor=abc123Trace the write first. The client sends POST /v1/items. A load balancer picks a stateless API server. The server validates the request and writes the record to the database. Anything that does not need to finish before the response, such as search indexing or notifications, goes onto a queue for workers.
Then trace the read. GET /v1/items/{item_id} is a lookup by key, so a cache in front of the database can answer most of it. The list endpoint reads by owner_id, so the data model needs an index or partition key on that field.
Your capacity numbers decide which boxes earn a place. With about 579 average write QPS and 11,574 average read QPS, the system is read-heavy by roughly 20 to 1. That ratio justifies a cache. It also suggests that read replicas may matter later. About 579 writes per second is modest for one primary database, so you do not need to shard the write path yet.
Label what you decided
Every arrow should carry a decision you can defend. Mark the diagram with short notes:
- Which calls are synchronous and which go through the queue.
- Which component is the source of truth. Here the database is. The cache and the index are derived copies.
- Which components are stateless and can be added freely. The API servers and workers qualify.
Common mistakes
- Drawing before choosing the flow. Boxes without request paths cannot be checked against the requirements.
- Hiding the source of truth. If two stores hold the same data, say which one wins when they disagree.
- Making everything synchronous. A write that waits for indexing and notifications is slower and fails more often.
- Skipping the single points of failure. One load balancer or one primary database is acceptable at this stage. Note it so you can return to it in the reliability step.
Walk it through aloud
Once the diagram exists, narrate one write and one read from client to storage and back. Check each step against the requirements list. If a functional requirement has no path, the design is incomplete. If a non-functional requirement, such as read latency, has no component supporting it, the design is unjustified.
Exercise
Using the items service above, a new requirement says users must see search results for an item within 5 seconds of posting it. Which part of the diagram handles this, and what would you check on that part?
Show answer
The queue, workers, and search index handle it, because indexing happens after the write response. Check the queue's end-to-end delay under peak write load (about 1,158 writes per second at a peak factor of 2) and that the workers can keep up. If the delay can exceed 5 seconds, add workers or index synchronously.