Chapter Two · Building Blocks

Scaling Reads and the Stateless Tier

Most systems an interviewer asks about are read far more often than they are written. Five lessons cover the tools for that shape: many stateless copies of the service, a cache in front of the store, the moments a cache makes things worse, read replicas and their lag, and the edge.

5 lessons

A read-heavy system has one useful property: most of its work is answering the same questions again. A link shortener resolves the same popular links all day, a feed serves the same posts to many readers, and a product page is viewed far more often than it changes. Every tool in this chapter exploits that repetition, and every one of them costs some freshness.

The chapter starts where scaling starts, with copies of a service that keep no state of their own, and moves outward along the read path. A cache absorbs repeated reads. The same cache, misused, can send the whole load to the store at once. Read replicas spread the reads a cache misses. At the edge, a content delivery network answers before the request reaches you. Each lesson ends on how interviewers probe it.

Where a read can be answered, nearest first
Clientits own copy
→
EdgeCDN
→
Cacheslocal, then shared
→
Storeprimary and replicas

Lessons in This Chapter