Latency Numbers
System Design
These numbers vary so hugely that it is difficult to really develop a sense of them. Some quick comparisons: it's 160x faster to read from RAM than do a random read from SSD. It's 4x faster to read 1MB sequentially from RAM than to do the same from SSD. Squares are scaled in size logarithmically.
Operation | Time | Visualization |
---|---|---|
L1 Cache Reference Fetching a hot variable in a running JavaScript function. | 0.5 ns | |
L2 Cache Reference Accessing slightly less frequent in-memory data. | 7 ns | |
L3 Cache Reference Resolving reused middleware configurations in Node.js. | 20-30 ns | |
Main Memory Reference Fetching data from a Redis cache stored in RAM. | 100 ns | |
Compress 1KB of Data in Memory Gzip compressing an HTTP response in Express.js. | 3,000 ns | |
Send 1KB over 1 Gbps Network Sending a small JSON response over the network. | 10,000 ns | |
SSD Random Read Querying a session ID from persistent Redis storage. | 16,000 ns | |
Read 1MB Sequentially from Memory Iterating through a large in-memory buffer of user data. | 250,000 ns | |
Read 1MB Sequentially from SSD Retrieving a 1MB file stored on disk for a static site. | 1,000,000 ns | |
Disk Seek Accessing a log file stored on a spinning disk. | 10,000,000 ns | |
Send Packet US to Europe and Back Calling an API hosted in a European data center. | 150,000,000 ns | |
Legend: 0.5 ns 1 ns 100 ns 1,000 ns 10,000 ns 1,000,000 ns 10,000,000 ns 150,000,000 ns |