SysDesignAtlas

The Numbers Underneath Everything

The memory hierarchy, and where the latency figures every engineer half-remembers actually come from — derived from physics and clock rates rather than memorised.

CoreEasy12 min readfundamentalshardwarelatencymemory
Confidence

#Why start with hardware

Almost every design decision in this atlas is a decision about where data lives. Cache or database. Memory or disk. Local disk or object storage. Same rack or another continent.

Those choices only make sense if you know what each option costs, and the costs are not arbitrary — they fall out of physics and clock rates. Once you can derive them, you stop memorising a table and start reasoning.

The single most important fact: the gaps between levels are enormous, and they are not linear. Each step down the hierarchy is roughly 10× to 1000× slower than the one above it.

#The hierarchy

CPU register ~1 KB · <1 ns L1 cache ~64 KB/core · ~1 ns L2 cache ~1 MB/core · ~4 ns L3 cache tens of MB, shared · ~15 ns Main memory (DRAM) hundreds of GB · ~80 ns NVMe SSD TBs · ~50-100 µs Network / remote storage unbounded · 0.2 ms to 150 ms
Each layer is bigger and dramatically slower than the one above it.

#Deriving the numbers

You do not need to remember these. You need to remember three anchors and derive the rest.

Everything else follows.

Why L1 is ~1 ns: it's physically adjacent to the core, a few clock cycles away. There is no mystery — it's close, so it's fast.

Why DRAM is ~80 ns: the memory controller has to select a row in a DRAM bank, wait for the sense amplifiers, and drive the result back across the bus. That's roughly 240 cycles. While it waits, a modern core will look ahead for later instructions that don't need the missing data and run those early ("out-of-order" execution). But most code soon needs the value it's waiting for, so the core still ends up stalled.

Why a same-datacenter round trip is ~0.5 ms: the fibre distance inside a datacentre is short, so cable length is not the cost — the cost is switching. Every hop through a switch adds queueing (waiting behind other packets) and serialisation (the time to push the packet's bits onto the next cable). Two to four hops each way, plus the operating system's networking code on both machines handling the packet, lands you around half a millisecond.

Why cross-continent is ~70 ms: New York to London is about 5,500 km of fibre. At 20 cm/ns that's 27 ms one way, 55 ms round trip — and real routes are not straight lines, so 70–80 ms is typical. No amount of engineering will fix this. It is the speed of light in glass.

#The table, with reasoning attached

OperationTimeRelative to L1Where it comes from
L1 cache reference1 ns1×~3 cycles, adjacent to the core
Branch mispredict3 ns3×The CPU guessed which way an if would go, guessed wrong, and binned the work
L2 cache reference4 ns4×~12 cycles
Mutex lock/unlock (uncontended)15 ns15×Taking a lock nobody else wants — one atomic instruction, plus telling other cores
L3 / last-level cache15 ns15×Shared across cores, further away
Main memory reference80 ns80×DRAM row activation + bus transfer
Compress 1 KB1 µs1,000×Real computation, thousands of cycles
Read 1 MB sequentially from memory20 µs20,000×Bandwidth-bound: ~50 GB/s
Datacenter round trip500 µs500,000×Switching + kernel stack, not distance
NVMe random read (4 KB)100 µs100,000×Flash read + controller + PCIe
Read 1 MB sequentially from NVMe300 µs300,000×~3 GB/s sequential
Disk seek (spinning)5 ms5,000,000×Physical arm movement
Cross-continent round trip70 ms70,000,000×Speed of light in fibre

#Sequential versus random is the other big gap

Latency numbers alone are misleading, because devices are far better at reading data laid out end to end (sequential) than at hopping between scattered locations (random).

One more unit before the diagram: IOPS is input/output operations per second — how many separate small reads or writes a device can do in a second, as opposed to how many bytes it can stream.

   NVMe SSD, same device:

     Random 4 KB reads     ~100 µs each, ~500K IOPS with deep queues
       → effective throughput on scattered small reads: ~2 GB/s

     Sequential read       ~3-7 GB/s streaming

   Spinning disk, same device:

     Random 4 KB reads     ~5-10 ms each  → ~150 IOPS  → ~0.6 MB/s
     Sequential read       ~200 MB/s

       → the gap on a spinning disk is over 300×

Two reasons this matters far beyond disks:

  1. It is why B-trees and LSM trees exist. These are the two main ways databases organise data on disk, and both are designs for turning random writes into sequential ones. See storage engines — the entire field of storage engineering is a response to this one asymmetry.
  2. It applies to memory too. DRAM reads happen in 64-byte cache lines. Reading one byte costs the same as reading 64. When you walk an array in order, the hardware spots the pattern and fetches the next lines before you ask (prefetching), so you run at full memory speed. A linked list is different: each node can sit anywhere in memory, and you only learn where the next one is after reading the current one. So every node costs a full ~80 ns trip to DRAM. The same data structure can be 10× apart in speed depending purely on layout.

#Bandwidth, and where it caps out

Latency tells you how long one operation takes. Bandwidth tells you how much data can move per second — and so how many operations you can keep going at once. Systems usually die of bandwidth, not latency: each request is fast enough, but there are too many bytes to move in total.

PathTypical bandwidth
L1 cache~1 TB/s per core
DRAM50–100 GB/s per socket
PCIe 5.0 x16~64 GB/s
NVMe SSD3–7 GB/s
Datacenter network card (NIC)25–400 Gb/s (≈3–50 GB/s)
Internet egress — data leaving you, heading to a user1–100 Mb/s, wildly variable

Two things fall out of this table.

Egress is the narrowest pipe in most products. A service that comfortably reads 5 GB/s from local NVMe may only be able to ship 3 GB/s to the network and far less to actual users. Bytes-on-the-wire is usually the real constraint — which is why compression, pagination (sending results a page at a time), and returning only the fields the client asked for matter more than they look.

GPU work inverts the usual intuition. You'd expect a GPU to be limited by how fast it can calculate. But to produce a single word, a language model has to read every weight in the model — often tens of gigabytes — out of GPU memory. GPU memory (HBM — the very fast memory stacked next to the chip) runs at 2–8 TB/s, and even that is the bottleneck: the arithmetic finishes long before the data arrives. The AI Foundations track works this out in detail, using the same bandwidth reasoning as this table, just with different hardware.

#Failure rates belong in this table too

Hardware is also a source of numbers you need for availability math.

ComponentRough annual failure rate
Spinning disk1–5%
SSD0.5–2%
Server (any cause)2–4%
Rack switch (top-of-rack)~1%
Whole-datacenter eventRare, but assume it happens

#Exercise

#Check yourself

What three anchors let you derive most latency numbers?Show answer
A clock cycle is about 0.33 ns (3 GHz); light in fibre covers about 20 cm per nanosecond; a DRAM access is about 80 ns, roughly 240 cycles.
Why can't engineering make a New York–London round trip much faster than ~70 ms?Show answer
It's the speed of light in glass: about 5,500 km at 20 cm/ns is ~27 ms each way, plus indirect routes. The only fix is to avoid the trip by putting the data near the reader.
Why does a same-datacentre round trip take ~0.5 ms when the cables are short?Show answer
Distance isn't the cost — switching is: queueing and serialisation at each switch hop, plus the kernel's network stack at both ends.
On a spinning disk, roughly how much faster is sequential reading than random 4 KB reads?Show answer
Over 300×: about 200 MB/s streaming versus ~150 random reads a second (~0.6 MB/s). That gap is why B-trees and LSM trees exist.
"Memory is random access, so layout doesn't matter." What's wrong with that?Show answer
DRAM is addressable at random, not fast at random: it reads 64-byte cache lines and prefetches in-order access. An array walked in order can be 10× faster than a linked list over the same data.
Which pipe is usually the narrowest in a product, and what follows from it?Show answer
Internet egress to users, at 1–100 Mb/s. Bytes on the wire are often the real limit, so compression, pagination and returning only the fields needed matter more than they look.
Why does fleet size change how you design for failure?Show answer
At 10,000 servers and 3% a year, about 300 fail annually — nearly one a day. Something is always broken, so failure has to be the normal path, not the exception.

#What to carry forward

  • Three anchors: 0.33 ns per clock, 20 cm per ns in fibre, 80 ns to DRAM. Derive the rest.
  • The hierarchy spans eight orders of magnitude. Which level your data sits on dominates everything else about your design.
  • Sequential beats random everywhere — in DRAM, on SSDs, catastrophically on spinning disks. Most storage design is a response to this.
  • Propagation delay is irreducible. Cross-region latency can only be avoided, never optimised.
  • At fleet scale, failure is continuous, not exceptional.
00:00
/ 12m