Chapter 17: Efficiency

Efficiency measures how much useful work a system produces per unit of resource consumed. A system that serves 10,000 requests per second on one server is more efficient than one that requires ten servers for the same throughput. At planetary scale, small efficiency improvements compound into enormous savings — a 10% improvement across a million servers frees up 100,000 servers' worth of resources.

Efficiency improvements come from every layer of the stack. At the algorithm level: a hash map lookup is O(1) versus O(n) for a linear scan. At the data structure level: our caching service's LRU eviction keeps the most useful data in memory. At the protocol level: connection pooling in the routing service eliminates per-request connection overhead. At the system level: the storage service's compaction reclaims disk space from deleted entries.

There is a tension between efficiency and other qualities like simplicity, reliability, and development velocity. Premature optimization often produces complex code that is hard to maintain and debug. The most effective approach is to build simple systems first, measure their performance in production, identify the actual bottlenecks (which are often not where you expect), and optimize surgically.