Cheatsheet
System Design Fundamentals
Latency numbers, units, back-of-envelope formulas, availability nines, SLIs and SLOs, percentiles and scaling on a few printable pages.
01Latency numbers (orders of magnitude)
These figures are approximate and vary by hardware and generation. Learn the ratios between rows, not the exact numbers: memory is about 100x slower than L1 cache, and a cross-continent round trip is about 100,000x slower than reading memory.
| Operation | Approximate time | Order of magnitude |
|---|---|---|
| L1 cache reference | ~1 ns | nanoseconds |
| L2 cache reference | ~4 ns | nanoseconds |
| Uncontended mutex lock/unlock | ~20 ns | nanoseconds |
| Main memory reference | ~100 ns | nanoseconds |
| Send 1 KB over a 10 Gbps link | ~1 µs | microseconds |
| Read 1 MB sequentially from memory | ~10–50 µs | microseconds |
| Random 4 KB read from NVMe SSD | ~20–100 µs | microseconds |
| Round trip inside one data centre | ~0.5 ms | sub-millisecond |
| Read 1 MB sequentially from SSD | ~0.2–1 ms | milliseconds |
| Disk seek (spinning HDD) | ~5–10 ms | milliseconds |
| Round trip between nearby regions | ~10–30 ms | milliseconds |
| Round trip across a continent or ocean | ~70–150 ms | tens to hundreds of ms |
- Avoid network round trips inside a request loop: ten sequential calls at 0.5 ms each cost 5 ms before any work is done.
- Memory beats SSD, SSD beats network to another region. Caching is about moving data up this table.
- The speed of light in fibre is about 200 km per ms; physics sets a floor on cross-region latency.
02Units and powers of ten
| Unit | Bytes | Power of ten | Close binary unit |
|---|---|---|---|
| KB (kilobyte) | 1,000 | 10^3 | KiB = 1,024 |
| MB (megabyte) | 1,000,000 | 10^6 | MiB ≈ 1.05 × 10^6 |
| GB (gigabyte) | 1,000,000,000 | 10^9 | GiB ≈ 1.07 × 10^9 |
| TB (terabyte) | 10^12 | 10^12 | TiB ≈ 1.10 × 10^12 |
| PB (petabyte) | 10^15 | 10^15 | PiB ≈ 1.13 × 10^15 |
| Period | Seconds | Shortcut |
|---|---|---|
| 1 minute | 60 | |
| 1 hour | 3,600 | |
| 1 day | 86,400 | ≈ 10^5 (round up for quick maths) |
| 1 month (30 days) | 2,592,000 | ≈ 2.6 × 10^6 |
| 1 year (365 days) | 31,536,000 | ≈ 3 × 10^7 (π × 10^7 is a common memory aid) |
- Bits vs bytes
- Network links are quoted in bits per second; storage in bytes. 1 byte = 8 bits, so 1 Gbps moves about 125 MB per second.
- 1 million per day
- About 12 per second on average (1,000,000 / 86,400 ≈ 11.6).
- 1 billion per month
- About 385 per second on average.
03Back-of-envelope formulas
average RPS = daily active users × requests per user per day / 86,400 peak RPS = average RPS × peak factor (2–5 is typical; measure it) bandwidth (bps) = RPS × payload bytes × 8 storage per day = new records per day × bytes per record total storage = per day × 365 × years × (1 + index overhead) × replication factor servers needed = ceil(peak RPS / (RPS per server × target utilisation)) + spares Little's law L = λ × W (in-flight requests = arrival rate × time in system)
- State assumptions out loud and round aggressively: 86,400 ≈ 100,000 is fine for an interview estimate.
- Separate reads from writes; they usually scale differently (caches absorb reads, writes hit the primary).
- Size for peak, not average, then add headroom so one failed instance does not overload the rest.
- Sanity-check the answer against a known system or a single machine’s limits.
10M DAU × 20 requests = 200M requests/day 200M / 86,400 ≈ 2,300 RPS average × peak factor 3 ≈ 7,000 RPS peak 7,000 × 20 KB × 8 ≈ 1.1 Gbps egress at peak Little's law at 50 ms: 7,000 × 0.05 = 350 requests in flight
04Availability and the nines
| Availability | Per year | Per month | Per week |
|---|---|---|---|
| 99% (two nines) | 3.65 days | 7.2 hours | 1.68 hours |
| 99.5% | 43.8 hours | 3.6 hours | 50.4 minutes |
| 99.9% (three nines) | 8.76 hours | 43.2 minutes | 10.1 minutes |
| 99.95% | 4.38 hours | 21.6 minutes | 5.04 minutes |
| 99.99% (four nines) | 52.6 minutes | 4.32 minutes | 1.01 minutes |
| 99.999% (five nines) | 5.26 minutes | 25.9 seconds | 6.05 seconds |
in series (all must work): A = A1 × A2 × … × An in parallel (any one works): A = 1 − (1 − A1) × (1 − A2) × … example: three 99.9% services in series → 99.7% example: two 99.9% replicas in parallel → 99.9999%
- Every synchronous dependency lowers your ceiling; you cannot be more available than the chain you call.
- Redundancy only helps when failures are independent: two replicas on the same rack, power feed or bad deploy fail together.
- Availability = MTBF / (MTBF + MTTR). Shrinking time to recover is often cheaper than preventing every failure.
05SLI, SLO and SLA
| Term | What it is | Example | Owned by |
|---|---|---|---|
| SLI (indicator) | A measured ratio of good events to total events | Requests answered in < 300 ms with a non-5xx status / all requests | Engineering |
| SLO (objective) | A target for an SLI over a window | 99.9% of requests good over 30 days | Engineering and product |
| SLA (agreement) | A contract with consequences if missed | Below 99.5% monthly → 10% service credit | Business and legal |
| Error budget | 1 − SLO: the unreliability you can spend | 0.1% of 30 days ≈ 43 minutes of bad requests | Shared |
- Set the SLA looser than the SLO so you notice and react before owing credits.
- Measure SLIs where users feel them (load balancer or client), not only inside the service.
- When the error budget is spent, slow down risky releases and prioritise reliability work.
06Latency, throughput and percentiles
- Latency
- Time for one request, from send to response. Report it as a distribution, never only as an average.
- Throughput
- Work completed per unit of time (requests per second, MB per second).
- P50 / P95 / P99
- The value below which 50%, 95% or 99% of requests fall. P99 = 400 ms means 1 request in 100 is slower than 400 ms.
- Tail latency
- The slow end of the distribution (P99 and above). It dominates when one page fans out to many backends.
- Utilisation
- Fraction of time a resource is busy. Queueing delay grows sharply as utilisation approaches 100%.
P(at least one slow call) = 1 − 0.99^n for n parallel calls, each with a 1% chance of hitting P99 n = 10 → 9.6% of page loads see a P99-slow backend n = 100 → 63%
- Averages hide outliers: a mean of 50 ms can coexist with a P99 of 2 s.
- Percentiles cannot be averaged across servers; aggregate the raw histograms instead.
- Higher throughput usually costs latency once queues form; keep utilisation below about 70–80% for latency-sensitive services.
07Vertical vs horizontal scaling
| Aspect | Vertical (scale up) | Horizontal (scale out) |
|---|---|---|
| How | Bigger machine: more CPU, RAM, faster disk | More machines behind a load balancer |
| Code changes | Usually none | Services must be stateless or share state externally |
| Ceiling | Largest available instance | Practically unbounded for stateless tiers |
| Failure impact | One machine is a single point of failure | Losing one node removes 1/N of capacity |
| Cost curve | Grows faster than linearly at the high end | Roughly linear, plus coordination overhead |
| Good first choice for | Databases, early-stage systems | Web and API tiers, workers |
- Scale up first when it is cheap; scale out when you need redundancy or pass a single machine’s limits.
- Move session state to a shared store (or tokens) before adding web servers.
- Plan N+1 (or N+2) capacity: enough instances that losing one still serves peak traffic.