Quick reference of latencies from a napkin-math tutorial for engineers. Useful when thinking about where a program spends its time, and when preparing for interviews.
The entities involved:
- CPU — 4 GHz ≈ 4 billion instructions/second
- CPU cache
- RAM (volatile memory)
- Disk (permanent memory)
- Networking
Typical latencies:
| Entity | Latency |
|---|---|
| CPU instruction | 1 ns |
| L1 cache | 1 ns |
| L2 cache | 3 ns |
| L3 cache | 10 ns |
| RAM | ~100 ns |
| NVMe SSD | ~50 µs |
| HDD | 1–10 ms |
| Storage (same region) | ~1 ms |
| East-West US | ~70 ms |
| US to EU | ~150 ms |
| US to APAC | ~200 ms |
There's no need to memorize every number from the README of the linked repo, but keeping this table in mind helps when looking for optimization gaps — for example, the gap between cache and RAM is much larger than the gap between L2 and L3.