Latency numbers

From an L1 cache hit to a trans-Atlantic round trip.

On this page
  1. Latency numbers visualized
  2. How old these numbers are
text
Latency Comparison Numbers
--------------------------
L1 cache reference                           0.5 ns
Branch mispredict                            5   ns
L2 cache reference                           7   ns                      14x L1 cache
Mutex lock/unlock                           25   ns
Main memory reference                      100   ns                      20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy            10,000   ns       10 us
Send 1 KB bytes over 1 Gbps network     10,000   ns       10 us
Read 4 KB randomly from SSD*           150,000   ns      150 us          ~1GB/sec SSD
Read 1 MB sequentially from memory     250,000   ns      250 us
Round trip within same datacenter      500,000   ns      500 us
Read 1 MB sequentially from SSD*     1,000,000   ns    1,000 us    1 ms  ~1GB/sec SSD, 4X memory
HDD seek                            10,000,000   ns   10,000 us   10 ms  20x datacenter roundtrip
Read 1 MB sequentially from 1 Gbps  10,000,000   ns   10,000 us   10 ms  40x memory, 10X SSD
Read 1 MB sequentially from HDD     30,000,000   ns   30,000 us   30 ms 120x memory, 30X SSD
Send packet CA->Netherlands->CA    150,000,000   ns  150,000 us  150 ms

Notes
-----
1 ns = 10^-9 seconds
1 us = 10^-6 seconds = 1,000 ns
1 ms = 10^-3 seconds = 1,000 us = 1,000,000 ns

Handy metrics based on numbers above:

  • Read sequentially from HDD at 30 MB/s
  • Read sequentially from 1 Gbps Ethernet at 100 MB/s
  • Read sequentially from SSD at 1 GB/s
  • Read sequentially from main memory at 4 GB/s
  • 6-7 world-wide round trips per second
  • 2,000 round trips per second within a data center

Latency numbers visualized#

The latency numbers drawn as squares, from a 0.5 ns L1 cache reference to a 150 ms packet round trip from California to the Netherlands, so the gaps of several orders of magnitude between memory, network, SSD and disk can be seen.
Sources and further reading4 links

Added on this site

How old these numbers are#

This table is the widely shared list from 2012, built on figures Jeff Dean presented in 2009 (see the sources below). Read it for the gaps between rows, not for exact values. A main memory reference is 200 times slower than an L1 cache hit, a round trip within a datacenter costs as much as 5,000 memory references, and a disk seek costs 20 of those round trips. Those orders of magnitude are what an interviewer expects you to know, and they still hold.

Some rows have moved since:

  • Storage got much faster. Current NVMe SSDs read sequentially at several gigabytes per second, against the table's 1 GB/s, so reading 1 MB from an SSD now takes a few hundred microseconds rather than a millisecond. Random reads are faster too.
  • Memory bandwidth grew. Reading 1 MB sequentially from memory is several times quicker than the 250 µs shown.
  • The CPU-level rows barely changed. Clock speeds stopped rising around the time the table was written, so cache references and branch mispredictions cost about the same.
  • Spinning disks did not change. A hard disk seek still takes around 10 ms, which is why they are now used for bulk and archive storage rather than for databases that serve requests.

When you use these numbers in an estimate, say that they are rough, and round them to the nearest power of ten. That is accurate enough to choose between designs.

Esc
↑ ↓ to move↵ to open