Lesson 3.3 · 15 min
Replication
Crash a leader under async, semi-sync and sync replication and count the acknowledged writes that vanish, then tune a leaderless quorum.
The idea in plain words
Replication keeps copies of the same data on several machines, like keeping photocopies of important papers in different buildings. If one building burns down, nothing is lost, and more people can read at once.
The problem it solves
If your data lives on one machine, losing that machine loses the data, and that machine is the limit on how many reads you can serve.
How it works
- One copy is the primary: it accepts all writes.
- It sends each change to the other copies (replicas), which apply them in the same order.
- Reads can go to replicas to spread the load.
- The primary can wait for replicas to confirm a write (safer, slower) or not wait (faster, but a crash can lose the newest writes).
- If the primary dies, a replica is promoted to take over (failover).
Example
A primary and two replicas. With asynchronous replication, the primary says “saved” right away; if it crashes a second later, a write that hadn’t reached the replicas is gone, even though the user saw success. With synchronous replication, “saved” means a replica has it too, at the cost of slower writes.
Key terms
- Primary (leader)
- The copy that accepts writes and sends them to the others.
- Replica (follower)
- A copy that receives changes from the primary and can serve reads.
- Synchronous
- The primary waits for replicas to confirm before telling the client “saved”.
- Asynchronous
- The primary confirms at once and sends changes later, so a crash can lose the latest writes.
- Failover
- Promoting a replica to primary when the primary dies.
- Split brain
- Two nodes both acting as primary at once, accepting conflicting writes.
In this lesson you'll learn
- What async, semi-sync and sync replication cost in write latency, and what a leader crash loses with each.
- When to use single-leader, multi-leader or leaderless replication.
- How quorums (R + W > N) and careful failover keep data safe.
Sections
- Theory: crash the leader
- Theory: who accepts writes
- Theory: quorums
- Design: pick a setup
- Check yourself
Cheat sheet
| Async | fast; a crash can lose acked writes |
|---|---|
| Semi-sync | no loss if you promote the acker |
| Sync to all | one dead follower blocks writes |
| Quorum | R + W > N; survives N − W down |
| Failover | promote freshest, fence the old leader |
The interactive simulations and the quiz load with JavaScript.