Lesson 7 of 17
14. Replication

14.6 How do you use read replicas in practice?

3 min read+10 XP

At the bank: Most customers just read notices, so the bank opens more branches for reading. Anything that changes an account still goes to head office.

In the system: Read replicas take read traffic off the leader:

  • Route by the kind of query: writes and read-after-write reads go to the leader; everything that can be slightly stale (book pages, search, recommendations, reports) goes to replicas. This is usually done in the app (separate connection pools) or by a database proxy.
  • Size them like any fleet (Chapter 2): if each replica handles 5,000 reads a second at full load and you keep them at 70%, 20,000 reads a second needs about 6 replicas.
  • Give heavy jobs their own replica: analytics and nightly reports on a dedicated replica, so a huge query doesn't slow users' reads or make the user-facing replicas lag.
  • Remove a lagging replica from rotation automatically.
  • Remember the limit: replicas don't help writes. If the leader is saturated by writes, you need a bigger leader or sharding (Chapters 6 and 15).

Memory code: "Reads to the branches, changes to head office."