Latency, by Pekka Enberg, fills a gap in the performance tuning space. While many authors have written about database tuning, systems tuning, or code optimization, I haven't seen any come together to cover the whole stack in such a comprehensive way, targeting both software engineers and database architects. Enberg brings a wealth of experience tuning distributed systems, formerly at ScyllaDB and now as CTO at Turso (distributed SQLite).
Having a shared vocabulary across database, software, and infrastructure teams is critical when working together to tune latency issues. I've been in many incident rooms where the only report is "the application is slow" and had to unwind a series of questions: What do you mean by slow? Where do you see this? What parts are slow? If everyone in the room had read Enberg's Latency, solving these kinds of incidents would be much faster. As one example, Enberg breaks down network latency (a small but critical part of the stack) into propagation latency, transmission latency, processing latency, and queueing latency. As another, he clarifies the differences between system service time, wait time, and response time. Each of these can point to a different problem to solve. While he provides the basic math when discussing topics like this, it's quickly followed up by a plain-English description.
Being very clear on terminology helps as well when architecting an application. Enberg digs into every bit of the stack: from physics to hardware, virtualization to the operating system, the managed runtime, and the network, application, and data storage layers. For each optimization discussed, he doesn't just provide best practices but rather shares the tradeoffs and decision points. For example, he covers replication from various angles: replication topologies (single-leader, multi-writer, leaderless), staleness vs. speed (synchronous, asynchronous), and distributed algorithms (RAFT, Paxos, Viewstamped).
Each of the concepts is illustrated with a clear example, and the chapter is capped with a use case scenario. Specific examples are given using TigerBeetle, SQLite, and ScyllaDB; while these are indeed database examples, they are presented from the point of view of a database developer, not a database operator. Developing database software requires thinking very hard about how to reduce latency, and whatever software you are writing, you will benefit from the examples. Many of these scenarios include code you can execute to, as he says, "build intuition." These are often using Rust; even though he states that Rust is not critical to low-latency applications, the case is well-made throughout that you might consider it if you have these needs.
Unique to this presentation are sections on predictive techniques (like prefetching data based on user patterns), eliminating work (the fastest way to do something is not to do it), and "hiding" latency when you can't reduce it (sometimes a batch job is just going to have to update a lot of rows). He covers specific methods in these sections that you can incorporate into your application and operational practices, although if he wrote another book with more details around these concepts, I would read it.
A book that covers so much material risks becoming page after page of bulletpointed lists. Enberg avoids this by organizing the concepts by the layers of the stack, summarizing each optimization concisely followed by 1-2 iterations of depth, providing real-world examples, and including tradeoffs to guide decisions. It will be hard to use this guide as a quick fix; you really need to sit with the whole thing end-to-end, but it is worth it. Especially if you are in an incident room with me in the future.
PS Don't skip the Appendix for further reading. Again, this isn't just a list of resources but rather puts each one in context.