Latency every engineer should know
| Operation | Time |
|---|---|
| L1 cache reference | ~1 ns |
| Branch mispredict | ~3 ns |
| L2 cache reference | ~4 ns |
| Mutex lock/unlock | ~17 ns |
| Main memory reference | ~100 ns |
| Compress 1 KB | ~2 µs |
| SSD random read | ~16 µs |
| Read 1 MB sequentially from memory | ~100 µs |
| Round trip within same datacenter | ~500 µs |
| Read 1 MB from SSD | ~1 ms |
| Disk seek (HDD) | ~10 ms |
| Read 1 MB from disk | ~20 ms |
| Round trip across continents | ~150 ms |
Takeaways: memory ≈ 100,000× faster than disk, a same-DC round trip is ~0.5 ms, and a cross-continent hop (~150 ms) dominates everything — so cache, and put data near users.
Powers of two (data sizes)
| Power | ≈ | Name |
|---|---|---|
| 2¹⁰ | 1 thousand | KB |
| 2²⁰ | 1 million | MB |
| 2³⁰ | 1 billion | GB |
| 2⁴⁰ | 1 trillion | TB |
| 2⁵⁰ | 1 quadrillion | PB |
Availability — the nines
| Availability | Downtime / year |
|---|---|
| 99% (two nines) | ~3.65 days |
| 99.9% (three nines) | ~8.8 hours |
| 99.99% (four nines) | ~52 minutes |
| 99.999% (five nines) | ~5 minutes |
Each extra nine is exponentially harder/costlier — redundancy, failover, multi-region. Match the target to the product, don't chase nines for free.
Capacity estimation recipe
- QPS:
DAU × actions/user/day ÷ 86,400. A day ≈ 10⁵ seconds. Peak ≈ 2–3× average. - Read:write: assume read-heavy (often 100:1) unless told otherwise → decide caching/replicas.
- Storage/year:
writes/day × bytes/write × 365(× replication factor). - Bandwidth:
QPS × payload size.
Worked example: 10M DAU, 10 reads + 1 write each → ~110M ops/day ÷ 10⁵ ≈ ~1.1k QPS average, ~3k peak. 1M writes/day × 1 KB ≈ ~365 GB/year before replication.
Nobody wants precision — they want to see that your numbers justify your design. "~3k peak QPS and 100:1 reads, so I'll add a cache and read replicas" is the whole point of estimating.