How fast memory, disk and network really are, and why those gaps shape every design.
Some numbers are worth remembering, because they tell you which design ideas are cheap and which are costly.
Every request in your system touches some mix of CPU caches, memory, disk and network. Each is fast or slow in a different way, so knowing the rough cost of each helps you guess where a design will be slow, before you build it.
| Operation | About how long | If 1 ns were 1 second |
|---|---|---|
| Read from L1 cache | 1 ns | 1 second |
| Read from L2 cache | 5 ns | 5 seconds |
| Read from main memory (RAM) | 100 ns | About 2 minutes |
| Random read from an SSD | 100 ยตs | About 28 hours |
| Round trip inside a data centre | 500 ยตs | About 6 days |
| Disk seek (spinning drive) | 10 ms | About 4 months |
| Round trip across a continent or ocean | 150 ms | About 5 years |
| Group | What to remember | What it means for design |
|---|---|---|
| CPU caches | Nanoseconds | Keep small, hot data together so it stays in cache |
| Memory (RAM) | About 100 ns, fast but costly and limited | Hold the working set here (caches, session data) |
| SSD | About 100 ยตs, roughly 1,000 times slower than RAM | Good for databases and warm data |
| Spinning disk | A seek costs about 10 ms. Sequential reads are fast | Use for cheap, big, mostly sequential data |
| Same data centre network | About half a millisecond per round trip | Cheap, but calls add up in a long chain |
| Cross-region network | Often 50 to 150 ms or more | Avoid on the main request path |
| Item | Rough value |
|---|---|
| A seek-free sequential read from memory | Many GB per second |
| A sequential read from an SSD | Hundreds of MB to several GB per second |
| A network link in a data centre | From 1 to 100 Gbps (125 MB/s to 12.5 GB/s) |
| A typical web page request over the internet | Tens to hundreds of ms, mostly network |
| A mobile network round trip | Tens to hundreds of ms, and it varies a lot |
Round numbers for a feel of the size, not exact facts. Real values depend on the hardware and change over the years (SSDs and networks keep getting faster). The gaps between the rungs stay huge.
| Term | Meaning in easy words |
|---|---|
| Latency | The time one operation takes from start to finish |
| Nanosecond (ns) | One billionth of a second |
| Microsecond (ยตs) | One millionth of a second (1,000 ns) |
| Millisecond (ms) | One thousandth of a second (1,000 ยตs) |
| Round trip (RTT) | The time for a message to go to a machine and come back |
| Cache | Small, fast storage that keeps copies of hot data |
| Cache hit / miss | The data was found in the cache, or it was not |
| Sequential vs random access | Reading in order versus jumping around. Sequential is much faster |
| Disk seek | Moving the read head of a spinning drive to a new place |
| Order of magnitude | A factor of 10. The gaps in this topic span many orders |
| Working set | The data a program uses often, which should fit in fast memory |
| Choice | We gain | We lose |
|---|---|---|
| Keep data in memory | Very fast reads | Cost per GB, and data may be lost on a crash unless saved |
| Use SSD instead of memory | Larger and cheaper storage | About 1,000 times slower reads |
| Call another service | Clear separation of work | A network hop on every request |
| Cache at many levels | Fewer slow trips | Stale data and invalidation work |
| Replicate across regions | Low latency for far users | Cost and consistency work |
| Compress data | Fewer bytes over the network | CPU time to compress and decompress |