SD·00
Start Here: Your First System Design
For readers who have built applications but never designed a system: what system design is, one small design worked end to end (the tiffin centre's menu and ordering) from requirements to numbers to a measured single server, why one machine often goes further than you think, where it eventually breaks and which building block fixes each limit, the vocabulary of the volume, and how to study it.
Start here: how to use this volume
Two reading paths
This volume is about designing systems that meet their requirements at the scale they'll actually face: discovering requirements, estimating, the building blocks, scaling, availability, caching, databases, messaging, consistency, reliability patterns, events, APIs, multi-tenancy and global systems, then complete case studies. Every chapter has the same shape: a plain-language Start here section with small, verified examples; a How deep to go ladder; the full-depth sections; a Lab of real measurements; and a Revision sheet.
- New to system design? Read this chapter, then the chapters in order. The labs use free tools on one machine: Go and Python services, PostgreSQL, Redis, HAProxy, NATS, etcd, wrk and k6.
- Experienced? Skip this chapter. In each chapter read the revision sheet first, take its quiz, then use How deep to go to choose the sections and lab experiments to study.
Mastery levels
Every chapter uses the same six levels:
| Level | Name | You can… | Example for caching |
|---|---|---|---|
| L1 | Recognition | define it and spot it | "that's a cache-aside read" |
| L2 | Working | apply it in a design | put a cache in front of a hot read path |
| L3 | Internals | explain why it works | explain hit ratio, skew, TTLs and stampedes |
| L4 | Debugging | find and fix problems | diagnose a stale-data bug or a cache stampede |
| L5 | Design | choose for a whole system | decide what to cache where, and how to invalidate it |
| L6 | Production | run it at scale | operate caching across many services and regions |
What system design is
Writing code answers "how do I make this feature work?". System design answers "how do I make it keep working for the people, data and load it will really have, when parts of it fail?". It is a chain of decisions, each one justified by a requirement and a number, and the most common mistake isn't choosing the wrong database: it's designing for a scale, or a failure, nobody asked about.
Step 1: requirements
The tiffin centre wants customers to browse today's menu and place orders.
- Functional: show the menu (200 dishes); place an order; see its status.
- Non-functional: menu pages load in under 200 ms for 99% of requests; ordering keeps working if one server dies; no order is ever lost or charged twice.
- Scale: 50,000 orders a day today; plan for 10× within two years.
Step 2: the numbers
orders: 50,000/day ÷ 86,400 s ≈ 0.6 orders/s on average
lunch peak ≈ 10× average ≈ 6 orders/s
menu views: ~20 per order → 1,000,000/day ≈ 12/s average, ≈ 120/s at peak
in two years (10×): ≈ 1,200 menu views/s at peak, 60 orders/s
menu size: 200 dishes ≈ 20 KB of JSON → 1,200/s × 20 KB ≈ 24 MB/s ≈ 190 Mbit/s
These are rough on purpose; a factor of two doesn't matter, a factor of a hundred does.
Step 3: measure one server
One small Go server on the lab machine (2 CPU cores), building the 20 KB menu JSON on every request, loaded with wrk using 32 connections:
/menu (build JSON per request): 2,972 requests/s p50 11.2 ms p99 84.1 ms
/menu-cached (pre-encoded bytes): 29,873 requests/s p50 0.9 ms p99 17.7 ms
The plain version already handles today's 120/s peak with 25× headroom, and even the two-year 1,200/s target. Encoding the menu once and serving the same bytes made it 10× faster: that is a cache, the simplest building block in this volume. The first lesson of system design is that a single, well-written server goes a long way; distribute only when a requirement forces you to.
Step 4: find what forces you to grow
The numbers say one server is fast enough. The other requirements say it isn't enough:
| Requirement or limit | Why one server fails it | Building block (chapter) |
|---|---|---|
| keeps working if a server dies | one server is a single point of failure | redundancy + load balancer (123, 125) |
| p99 < 200 ms for users far away | distance adds latency | CDN, regions (126, 134) |
| no order lost | a crashed process loses in-memory work | durable database, replication (127) |
| no double charge | retries repeat actions | idempotency keys (130, 132) |
| kitchen screens update live | polling wastes capacity | messaging / events (128, 131) |
| 10× growth in writes | one database has a write ceiling | partitioning, queues (124, 127) |
Each row is a reason, stated in terms of a requirement, for adding complexity. A design without such a reason for each box is over-engineered.
How to study system design
A routine that works
- Always start from requirements and numbers, even for practice problems; write them down before drawing anything.
- Measure a single box first (the labs show how), so your estimates of capacity are real.
- For every component, say which requirement it serves and how it fails.
- Work through the case studies in the last chapter with the method from chapter 121, then compare.
- Read real architectures (engineering blogs, postmortems) and identify the requirement behind each choice.
Warm-up exercises
- Estimate requests per second for an app you use daily, from its user count and your own usage.
- Measure one endpoint of a service you've written with wrk or k6 and work out how many users one instance could serve.
- For a system you know, list three single points of failure and what removing each would cost.
- Find one engineering blog post about a scaling change and name the requirement that forced it.
Glossary
- Functional / non-functional requirement: what the system does / how well (latency, availability, durability, cost).
- QPS: queries (requests) per second; peak-to-average ratio: how much busier the busiest period is.
- Capacity: the load a component can serve while meeting its targets.
- Single point of failure: a component whose failure stops the whole system.
- Building block: a reusable component (load balancer, cache, queue, database, CDN).
- Trade-off: gaining one property at the cost of another.