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.
#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
#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
| Operation | Time | Relative to L1 | Where it comes from |
|---|---|---|---|
| L1 cache reference | 1 ns | 1× | ~3 cycles, adjacent to the core |
| Branch mispredict | 3 ns | 3× | The CPU guessed which way an if would go, guessed wrong, and binned the work |
| L2 cache reference | 4 ns | 4× | ~12 cycles |
| Mutex lock/unlock (uncontended) | 15 ns | 15× | Taking a lock nobody else wants — one atomic instruction, plus telling other cores |
| L3 / last-level cache | 15 ns | 15× | Shared across cores, further away |
| Main memory reference | 80 ns | 80× | DRAM row activation + bus transfer |
| Compress 1 KB | 1 µs | 1,000× | Real computation, thousands of cycles |
| Read 1 MB sequentially from memory | 20 µs | 20,000× | Bandwidth-bound: ~50 GB/s |
| Datacenter round trip | 500 µs | 500,000× | Switching + kernel stack, not distance |
| NVMe random read (4 KB) | 100 µs | 100,000× | Flash read + controller + PCIe |
| Read 1 MB sequentially from NVMe | 300 µs | 300,000× | ~3 GB/s sequential |
| Disk seek (spinning) | 5 ms | 5,000,000× | Physical arm movement |
| Cross-continent round trip | 70 ms | 70,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:
- 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.
- 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.
| Path | Typical bandwidth |
|---|---|
| L1 cache | ~1 TB/s per core |
| DRAM | 50–100 GB/s per socket |
| PCIe 5.0 x16 | ~64 GB/s |
| NVMe SSD | 3–7 GB/s |
| Datacenter network card (NIC) | 25–400 Gb/s (≈3–50 GB/s) |
| Internet egress — data leaving you, heading to a user | 1–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.
| Component | Rough annual failure rate |
|---|---|
| Spinning disk | 1–5% |
| SSD | 0.5–2% |
| Server (any cause) | 2–4% |
| Rack switch (top-of-rack) | ~1% |
| Whole-datacenter event | Rare, but assume it happens |
#Exercise
#Check yourself
What three anchors let you derive most latency numbers?Show answer
Why can't engineering make a New York–London round trip much faster than ~70 ms?Show answer
Why does a same-datacentre round trip take ~0.5 ms when the cables are short?Show answer
On a spinning disk, roughly how much faster is sequential reading than random 4 KB reads?Show answer
"Memory is random access, so layout doesn't matter." What's wrong with that?Show answer
Which pipe is usually the narrowest in a product, and what follows from it?Show answer
Why does fleet size change how you design for failure?Show answer
#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.