Introduction to System Design
System design is the process of defining the architecture, components and data flow of a system so that it meets its requirements at the required scale.
A repeatable approach
- Clarify requirements: functional (what it does) and non-functional (scale, latency, availability, consistency).
- Estimate: users, requests per second, storage, bandwidth.
- Define the API and the core data model.
- Sketch the high-level design: clients, services, storage, caches, queues.
- Deep dive into the bottlenecks and trade-offs.
- Review: failures, monitoring, security, cost, evolution.
Non-functional requirements
| Term | Meaning |
|---|---|
| Scalability | Handle growth in load |
| Availability | Fraction of time the system is up |
| Latency | Time to serve one request |
| Throughput | Requests handled per second |
| Consistency | Do all readers see the latest write? |
| Durability | Committed data is not lost |
Availability in "nines"
| Availability | Downtime per year |
|---|---|
| 99% | about 3.65 days |
| 99.9% | about 8.8 hours |
| 99.99% | about 53 minutes |
| 99.999% | about 5 minutes |
Back-of-the-envelope estimation
Useful numbers:
| Item | Value |
|---|---|
| Seconds per day | about 86,400 (round to 10^5) |
| 1 million requests per day | about 12 requests per second |
| Memory read | about 100 ns |
| SSD read | about 100 microseconds |
| Datacenter round trip | about 0.5 ms |
| Cross-continent round trip | about 150 ms |
estimate.py
daily_users = 10_000_000
requests_per_user = 20
qps = daily_users * requests_per_user / 86_400
peak_qps = qps * 3 # typical peak factor
print(round(qps), round(peak_qps)) # ~2315, ~6944
Trade-offs to name explicitly
- Consistency vs availability (CAP).
- Latency vs throughput.
- Read-optimised vs write-optimised designs.
- Simplicity vs flexibility; build vs buy.
Loading Comments...