Replication

Replication is keeping copies of the same data on multiple nodes, and it's the answer to two different problems at once — surviving failures and serving reads at scale. The hard part is never the copying; it's what happens when the copies disagree, which they always eventually do.

If a single machine holds your only copy of the data, that machine’s failure is your data’s death, and its capacity is your read ceiling. Replication — maintaining copies of the data on several nodes — solves both: copies survive individual failures, and reads can be spread across them. But the instant you have more than one copy, you inherit the problem that shaped the whole series — keeping them consistent when writes arrive and nodes fail. This post covers the three replication architectures and the trade-offs baked into each.

Why replicate

Three distinct motivations, often conflated:

These pull in different directions — scaling reads wants many replicas everywhere, but more copies make consistency harder and writes slower — which is why there are several architectures rather than one.

Single-leader replication

The most common design: one replica is the leader (primary), and all writes go to it. The leader applies each write locally, then streams the changes to its followers (replicas), which apply them in the same order. Reads can be served by the leader or any follower.

        writes
          │
          ▼
      ┌────────┐   replication stream   ┌──────────┐
      │ LEADER │ ─────────────────────▶ │ FOLLOWER │  ◀─ reads
      └────────┘ ─────────────────────▶ ┌──────────┐
                                        │ FOLLOWER │  ◀─ reads
                                        └──────────┘

The central choice is synchronous vs. asynchronous replication:

Single-leader is simple and gives a clean consistency story (one place decides write order), but it has two costs: the leader is a write bottleneck and a single point of failure, so you need failover (promote a follower when the leader dies — itself a consensus problem, covered next post), and asynchronous followers serve stale reads, which is where the session guarantees from the consistency models post earn their keep.

Multi-leader replication

When one leader isn’t enough — typically multi-datacenter setups where you want a local leader in each region — you can have multiple leaders, each accepting writes and replicating to the others. This improves write availability and latency (write to your nearest leader) and tolerates a datacenter outage.

The price is severe and unavoidable: write conflicts. Two leaders can accept conflicting writes to the same key concurrently, and because they’re separated, neither sees the other in time. Now you must detect the conflict (this is exactly what the vector clocks from the time and ordering post are for) and resolve it — via last-write-wins (simple but data-losing), application-defined merge logic, or conflict-free data types (CRDTs) that merge deterministically. Multi-leader buys write locality and availability at the cost of conflict handling, so reach for it only when a single leader genuinely can’t meet your latency or availability needs.

Leaderless replication

The third architecture drops the leader entirely: any replica accepts writes, and the client (or a coordinator) writes to several replicas and reads from several, using quorums to stay consistent. This is the Dynamo-style design behind systems like Cassandra.

The mechanism is the quorum condition. With N replicas, if you require W replicas to acknowledge a write and R replicas to answer a read, then setting W + R > N guarantees the read set and write set overlap in at least one replica — so a read is guaranteed to see the latest write:

N = 3, W = 2, R = 2  →  W + R = 4 > 3  ✓  (read and write sets always overlap)

Quorums make the consistency/availability trade tunable per operation, connecting directly to CAP:

Because writes may reach only some replicas, leaderless systems repair divergence in the background — read repair (fix stale replicas noticed during a read) and anti-entropy (a background process that syncs replicas) — and use vector clocks to detect concurrent writes. Leaderless trades the simplicity of a single write-order authority for high availability and per-request tunability, pushing conflict handling into the read path.

Choosing an architecture

Every architecture makes the same fundamental trade in a different place: how much do writes coordinate, and where do you pay for disagreement — at write time (synchronous), at failover, at read time (quorums/repair), or in conflict resolution (multi-leader). There is no copy-free lunch. The one thing all three eventually need — agreeing on who the leader is, or on a single order of operations despite failures — is consensus, the subject of the next post.

Key takeaways

Further reading

Sources & References