Database Replication: Single-Leader, Multi-Leader & Leaderless
Keeping multiple copies of the same data close enough to identical that a client can't tell which copy just answered.
Intermediate
UPDATE orders ... goes to the leader, but a read-heavy query like "show me this restaurant's order history" can be served from a follower without touching the leader at all — spreading read load across as many followers as needed.| Pro | Con | |
|---|---|---|
| Single-leader | Simple mental model; reads scale by adding followers; a follower can be promoted to leader on failure | All writes still funnel through one node — a write-heavy workload eventually bottlenecks there |
| Mode | Behavior | Trade-off |
|---|---|---|
| Synchronous | The leader waits for a follower to confirm the write before acknowledging it to the client. | Zero data loss if the leader fails right after, but higher write latency, and availability drops if that follower is slow or unreachable. |
| Asynchronous | The leader acknowledges the write immediately and replicates to followers in the background. | Low write latency, but a leader crash right after a write can lose data that never made it to any follower — and followers can serve stale reads until they catch up. |
n replicas, a write must be acknowledged by at least w of them, and a read must query at least r of them. As long as w + r > n, at least one node in any read set is guaranteed to have seen the latest write.
n = 3 replicas, w = 2, r = 2
w + r = 4 > n = 3 -> every read overlaps with at least one up-to-date replica
w and r — but it pushes conflict resolution to the client or a merge strategy, since with no single leader there's no natural "correct" order for concurrent writes to the same key.