LOAD-BEARINGfree
High-level designTier 4 · unit 4 of 7 · 14 min read

Replication and read replicas

Replication means keeping copies of your data on multiple machines. Two motivations, both excellent: read capacity (many copies can serve many readers) and survival (a machine dies; its copy wasn't the only one). The catch — and the source of one of the most common bugs in production software — is that copies take time to copy. Let's walk the four arrangements, from everyday to exotic.

Leader–follower: the workhorse

One node — the leader — accepts all writes and streams its change log to followers, which apply the changes and serve reads. Writes have one home (no conflicts possible); reads scale by adding followers. This is the default nearly everywhere, and it's the right default.

The cost is replication lag: followers run slightly behind — milliseconds normally, but seconds under load or during a big migration. And lag produces the classic bug you will absolutely meet:

A user posts a comment. The write goes to the leader. The app redirects to the page, which reads from a follower — one that hasn't received the comment yet. The user's own comment has vanished before their eyes. Nothing crashed, no errors — just a lagging copy, doing its best.

Fixes, in the order to try: read-your-own-writes — route a user's reads to the leader for a short window (say 10 seconds) after they write; or pin the whole session to the leader briefly; or, most precisely, have the client pass the log position its write reached, and only serve reads from replicas that have caught up to it. All three implement the same promise: you will always see what you yourself just did — which is the piece users actually notice.

Failover: when the leader dies

Three problems arrive at once: pick the most caught-up follower to promote (promote a laggard and its missing writes are lost); redirect all writers to it; and — the treacherous one — make sure the old leader, if it wakes back up, doesn't keep accepting writes. Two nodes both believing they're leader is split brain: two divergent histories for the same data, and an unpleasant week reconciling them. Automatic failover needs a consensus-based coordinator to decide leadership safely (Tier 6 builds exactly this); manual failover needs an awake human and a runbook. Both are legitimate choices. What's not legitimate is having neither and hoping.

Multi-leader: writes in many places

Sometimes you want writes accepted in several regions — Mumbai users write in Mumbai, London users in London, everyone gets local write latency. But now the same record can be edited in two places concurrently, and someone must resolve the conflict: last-write-wins (simple, and silently discards one edit — data loss as a feature), CRDTs (data types mathematically built to merge concurrent updates — correct, but only certain shapes of data qualify), or application-level merge (your code decides — powerful, laborious). Multi-leader is real medicine with real side effects; take it only with a diagnosis.

Leaderless: quorums instead of a boss

The Dynamo family (Cassandra, DynamoDB) drops the leader concept entirely: clients write to several nodes and read from several nodes. With N replicas, writing to W and reading from R, the guarantee is simple arithmetic: if W + R > N, the read set and write set must overlap in at least one node — so every read touches at least one node holding the latest write. N=3, W=2, R=2 is the classic configuration: survives a node failure, no single point of failure, decent speed both ways. The appeal is that it's tunable per query — bump W and R for a critical read, drop them for a casual one. Tier 6 goes deeper.

The trap

Adding read replicas to fix a write bottleneck. Walk through what a replica does: it receives and applies every single write the leader takes — that's what makes it a replica. So replicas multiply read capacity only; the write path still funnels through one leader, now with extra replication work on top. If writes are the problem, replicas make it very slightly worse. The tools for write scaling are batching, queueing — and ultimately the next lesson.

The tradeoff sheet

Problem solved
A single primary that cannot serve the read volume, and the absence of anything to fail over to when it dies.
Rejected, and why
Vertical scaling is simpler until the largest instance runs out. A cache is cheaper for hot keys and does nothing for the long tail of cold reads a replica handles well.
The trade
Replication lag becomes an application concern: a read after a write can legitimately return the old value, and every read path must decide whether it can tolerate that.
First to break at 10x
Write throughput, which replicas do not help at all, and lag under bulk writes — a backfill can push replicas minutes behind, at which point read-your-writes breaks everywhere at once.
What it does to the bill
Linear in replicas, plus cross-AZ replication traffic that is charged and rarely modelled. Three replicas is three primaries you are paying for.
Day-2 operations
Alert on replication lag in seconds and bytes. Rehearse failover before you need it, and know whether yours is automatic — an unrehearsed failover is a second incident inside the first.