Replication Strategies: Single-Leader vs Leaderless
On this page
Why replicate data
Keeping copies of data on several nodes serves three goals: availability (keep working when a node fails), read scaling (spread reads), and latency (serve users from nearby). How writes reach the copies is the key design choice, and it decides whether conflicts can happen at all.
Single-leader replication
One leader accepts all writes and streams changes to followers, which serve reads. PostgreSQL, MySQL, SQL Server, MongoDB replica sets and Kafka partitions work this way.
- Simple and conflict-free: one node orders all writes.
- Write throughput is limited to one node, unless data is partitioned so each partition has its own leader.
- Failover is the hard part: detect the leader's failure, promote a follower, redirect clients, and handle writes the old leader accepted but didn't replicate (lost with asynchronous replication).
- Reading from followers brings replication lag (Day 12).
Multi-leader replication
Several nodes accept writes, typically one leader per data center, and replicate to each other asynchronously.
- Low write latency everywhere: users write to their local data center.
- Survives a data center outage without failover for writes.
- Conflicts: two leaders can accept different writes to the same record at the same time. They must be detected and resolved (Day 10), and every resolution strategy has costs.
- Also appears in offline-capable clients: a phone app that accepts edits while offline is a leader that syncs later.
Leaderless replication
Any replica accepts writes. The client (or a coordinator) sends each write to several replicas and reads from several, using quorums to make reads see recent writes (Day 9). Amazon's Dynamo design popularized it; Cassandra and Riak follow it.
- No failover: a down replica is just one that didn't answer; others carry on.
- Tunable consistency per operation through quorum sizes.
- Repair mechanisms are required: read repair and anti-entropy bring stale replicas up to date (Day 13).
- Concurrent writes to the same key still conflict and need resolution.
Single-leader vs multi-leader vs leaderless
| Single-leader | Multi-leader | Leaderless | |
|---|---|---|---|
| Who accepts writes | One leader | A leader per site | Any replica |
| Write conflicts | None | Yes | Yes |
| Leader failure | Failover needed | Other leaders continue | Not applicable |
| Write latency for distant users | High (go to the leader) | Low (local leader) | Low with local quorums |
| Complexity | Lowest | High (conflict handling) | Medium-high (quorums, repair) |
| Examples | PostgreSQL, MongoDB, Kafka | Multi-region active-active setups, CouchDB, offline apps | Cassandra, Riak, DynamoDB's internals |
Synchronous vs asynchronous replication
Independent of topology: does a write wait for replicas before being confirmed?
- Synchronous: confirmed writes survive a node loss, but a slow replica slows every write.
- Asynchronous: fast, but recently confirmed writes can be lost on failover.
- Semi-synchronous: wait for one replica (or a majority) and let the rest catch up. The usual production compromise.
Check yourself
All writes go through one leader, which applies them in a single order and replicates that order to followers. Two clients can still race, but the leader decides who wins, so replicas never hold conflicting versions.
Low-latency writes in several regions and tolerance of a data center outage, at the cost of concurrent conflicting writes that must be resolved.
The write succeeds if enough other replicas acknowledge it; the down replica is repaired later through hinted handoff, read repair or anti-entropy.
If the leader fails before followers receive its latest writes, a follower is promoted without them, and those acknowledged writes are lost.
The leader waits for at least one follower to confirm each write before acknowledging, while others replicate asynchronously. It ensures two copies without waiting for every follower.