Topic 019 / Core
Latency numbers every engineer should know
Chapter 2.3 · Estimation and Workload Modeling
What and why
Without a feel for relative costs, an engineer can't tell whether a design decision matters — is one more network hop a rounding error, or the whole latency budget? This topic is a small table of approximate, rounded order-of-magnitude costs for common operations (cache, memory, disk, network), used to reason about where time goes in a system — not exact figures for any specific hardware. Builds on: → 9 (CPU, RAM, storage and I/O) — this turns that hardware hierarchy into numbers kept in your head.
Diagram
| Operation | Approximate cost (illustrative orders of magnitude; measure your own — the Part 1 exercise did) |
|---|---|
| L1/L2 cache reference | ~1 ns |
| RAM access | ~100 ns |
| SSD read | ~100 µs |
| Disk (HDD) seek | ~10 ms |
| Same-datacenter network round trip | ~0.5 ms |
| Cross-continent network round trip | ~100+ ms |
How it works
- Memorize the table as ratios, not absolutes: RAM is ~100× slower than cache; SSD is ~1,000× slower than RAM; a same-datacenter round trip is roughly 1,000× an SSD read; a cross-continent round trip is roughly 100–200× a same-datacenter one.
- To estimate a request's latency, add the cost of every hop it makes, in sequence.
- Identify which hop dominates the total — usually the network, almost always once it leaves the datacenter.
- Spend optimization effort on the dominant hop — shaving a RAM lookup when the same request also makes a cross-continent call is wasted effort.
- Re-measure on real hardware when a decision is close; this table is for order-of-magnitude reasoning, not a budget trusted to the millisecond.
Practical example
(illustrative). A request does 1 RAM lookup (~100 ns), 1 SSD read (~100,000 ns), and 1 same-datacenter round trip (~500,000 ns). Total ≈ 100 + 100,000 + 500,000 = 600,100 ns ≈ 0.6 ms, with the network hop alone ≈ 500,000 / 600,100 ≈ 83% of the total. If that same request instead crosses continents (~100,000,000 ns), the total becomes ≈ 100,100,100 ns ≈ 100.1 ms, with the network hop now ≈ 99.9% of the total — the RAM and SSD costs become irrelevant by comparison.
When to use it
- Use when: comparing design options that differ in the number or type of hops (an extra cache read vs. an extra network call).
- Avoid when: citing these numbers as exact — hardware, drivers, and virtualization change them, sometimes by a lot.
- Failure scenarios: optimizing an in-memory computation while ignoring an unnecessary network round trip that costs 1,000× more.
- Simpler alternative: a single-machine script with no network or disk I/O on its hot path gets no benefit from this table — skip the exercise.
Practice
(Numeric kind — five drills with an answer key; 15–20 min, no lab services).
- How many times slower is an SSD read (~100 µs) than a RAM access (~100 ns)?
- A request makes 3 sequential RAM lookups and 1 same-datacenter round trip (~0.5 ms). What's the total latency, and what fraction is the network hop?
- How many times slower is a cross-continent round trip (~100 ms) than a local SSD read (~100 µs)?
- A page load makes 2 cross-continent round trips (~100 ms each) and 1 same-datacenter round trip to a cache (~0.5 ms). Approximate the total latency.
- A disk-seek-bound scan (no index) does 5 sequential HDD seeks (~10 ms each). How does the total compare to one cross-continent round trip (~100 ms) — longer, shorter, or about the same?
Answer key.
- 100 µs = 100,000 ns; 100,000 / 100 = 1,000× slower.
- 3 × 100 ns = 300 ns ≈ 0.0003 ms; total ≈ 0.0003 + 0.5 = ≈0.5003 ms, of which the network hop is ≈ 0.5 / 0.5003 ≈ 99.94%.
- 100 ms = 100,000 µs; 100,000 / 100 = 1,000× slower.
- 2 × 100 ms + 0.5 ms = 200.5 ms.
- 5 × 10 ms = 50 ms vs. 100 ms for one cross-continent round trip — the five seeks total half as long (shorter).
Done when all five answers match the key.
Key takeaway
A handful of rounded order-of-magnitude numbers — cache, memory, disk, network — let you spot which hop in a design dominates, without measuring anything yet. Done when you can estimate a multi-hop request's latency and name the dominant hop from memory. Used next in → 20 (estimation), → 100 (latency/throughput/tail latency).
References
None — this topic makes no external claims.
Source directory