Skip to main content

Latency numbers worth memorising

The point of knowing these is not recall for its own sake. It is being able to reject a design in thirty seconds, before anyone builds it — "that is four cross-region round trips on the read path, so the floor is 600 ms, so no."

The absolute values drift with hardware. The ratios barely move, and the ratios are what the arithmetic needs.

The table​

Jeff Dean's numbers, with what each one actually tells you.

OperationTimeWhat it means for a design
L1 cache reference0.5 nsFree. Never reason about it.
Branch mispredict5 nsFree unless you are writing a hot inner loop.
L2 cache reference7 ns~14× L1. Still free.
Mutex lock/unlock25 nsCheap uncontended. Contention is a different problem entirely.
Main memory reference100 ns~200× L1. This is where cache-miss cost starts being visible.
Compress 1 KB (Snappy)10 µsCompressing before a network hop is almost always worth it.
Send 1 KB over 1 Gbps10 µsSerialisation cost, not distance.
Read 4 KB randomly from SSD150 µs~1,500× main memory.
Read 1 MB sequentially from memory250 µs
Round trip within a datacenter500 µsThe unit of distributed-systems cost. Memorise this one.
Read 1 MB sequentially from SSD1 ms~4× the same read from memory.
Disk seek (HDD)10 ms20× a datacenter round trip. Going to spinning disk is worse than going to another machine.
Read 1 MB sequentially from 1 Gbps10 ms
Read 1 MB sequentially from HDD30 ms
Packet CA → Netherlands → CA150 msThe speed of light is not negotiable.

Derived throughput, which is often the more useful form:

Sequential throughput
HDD30 MB/s
1 Gbps Ethernet100 MB/s
SSD1 GB/s
Main memory4 GB/s

And the two that end most arguments:

  • ~2,000 round trips per second within a datacenter.
  • ~6–7 round trips per second around the world.

Scaled to human time​

Multiply everything by a billion, so 1 ns becomes 1 second. The shape of the problem becomes obvious:

OperationHuman scale
L1 cache reference0.5 s — a heartbeat
Main memory reference1.7 minutes
SSD random read1.7 days
Datacenter round trip5.8 days
Disk seek16 weeks
Cross-Atlantic round trip4.8 years

A cache miss is a coffee break. A cross-region call is a university degree.

Which of these have aged​

The list dates from around 2012. Treat it as orders of magnitude that still hold, with three caveats where the hardware genuinely moved:

  • Network bandwidth. 1 Gbps was the assumption. 10 and 25 Gbps are ordinary inside a datacenter now, so the "send 1 KB" and "read 1 MB over the network" rows are pessimistic by roughly 10–25×.
  • SSDs. NVMe changed the picture: sequential reads of several GB/s and random 4 KB reads well under 100 µs are normal. The row is pessimistic by a few times.
  • Spinning disks. Largely gone from latency-sensitive paths. The 10 ms seek is still the right number for the archival tier, and still the right reason not to put it on a read path.

What has not changed, and will not: main memory around 100 ns, a datacenter round trip around 0.5 ms, and the cross-continent figure, which is bounded by physics rather than engineering.

The three rules that fall out​

  1. Memory, disk and network are decades apart, not percentages apart. Optimising the wrong layer by 20% is noise next to removing one round trip.
  2. Sequential beats random by a lot, at every layer. This is why storage engines are shaped the way they are — see storage engines.
  3. Distance is a hard floor. No amount of caching, threading or protocol cleverness gets a packet across the Atlantic faster than ~75 ms each way. If a design needs a synchronous cross-region hop on the critical path, the latency budget is already spent.

Where this gets used​

Sources​