cheat sheets / latency-numbers · 3-min read

Latency Numbers Cheat Sheet

From an L1 cache hit to a cross-continent round trip, in round orders of magnitude.

The table

Round orders of magnitude. Real figures vary by hardware and generation; use these to compare, not to promise.

L1 cache hit~1 ns
Branch mispredict~5 ns
L2 cache hit~5 ns
Uncontended mutex lock/unlock~20 ns
Main memory access~100 ns
Context switch~1–5 µs
Send 1 KB over a 10 Gbit/s link~1 µs
Read 1 MB sequentially from memory~50 µs
Random 4 KB read, flash SSD~100 µs
Round trip within a data centre~500 µs
Read 1 MB sequentially, flash SSD~1 ms
Spinning disk seek~10 ms
Round trip, same continent~30 ms
Round trip, across an ocean~150 ms

Scaled to human time

If an L1 hit took 1 second:

main memory     ~ 2 minutes
SSD random read ~ 1 day
in-DC round trip ~ 6 days
disk seek       ~ 4 months
ocean round trip ~ 5 years

How to use it

Count the slow steps on a request path and add them up before writing code. Two cross-ocean round trips already cost 300 ms, no matter how fast the server is. Most big wins come from removing a whole level — a network hop, a disk read — not from shaving instructions.

FAQs

Why do the memory and network numbers barely improve over the years?

Memory latency is limited by physics and DRAM design; network round trips by the speed of light in fibre. Bandwidth grows much faster than latency falls.

Where do these figures come from?

They follow the widely shared table popularised by Peter Norvig and Jeff Dean, rounded and adjusted to current hardware generations.

Sources

  1. Norvig, P. — Teach Yourself Programming in Ten Years (includes the original timing table)
  2. Drepper, U. — What Every Programmer Should Know About Memory (2007)

Related