Latency numbers every programmer should know
Play this lessonThis lesson comes with an interactive animation you can break, a live-code challenge and a chapter quiz.Google's Jeff Dean published how long typical computer operations took (2010). Hardware is faster now, but the ratios still hold, and that's what matters. In the animation, the right column imagines that 1 nanosecond = 1 second so the gaps feel human-sized.
Units: 1 ns = 10⁻⁹ s, 1 µs = 1,000 ns, 1 ms = 1,000 µs = 1,000,000 ns.
Conclusions
- Memory is fast; disk is slow.
- A disk seek is one of the most expensive things you can do, so design around it.
- Simple compression costs microseconds, far less than shipping extra bytes across the world.
- So compress data before it travels over the internet.
- Data centers sit in different regions, and every trip between them costs a long round trip.
Key takeaways
- Memory ≫ network in a data center ≫ disk ≫ cross-continent.
- Design to keep hot data in memory and avoid unnecessary disk seeks and long-distance round trips.