Replication
Copy state across machines without confusing more copies with stronger correctness.
2–5 minute refresher
Leaderaccept writes
replicate ↓
Follower A
Follower B
Follower C
Accept change → order it → copy it → confirm it → repair lag
30second
refresher
refresher
Replication keeps multiple copies of data for availability, read scale, durability, and geographic proximity. Common shapes are leader/follower, multi-leader, and leaderless; each moves ordering and conflict work to a different place.
How it works
In leader/follower replication, one node orders writes and streams them to followers. Synchronous acknowledgement waits for selected followers. Asynchronous acknowledgement responds earlier and lets replicas catch up later.
Decision guide
Key trade-offs
| Choice | What you gain | What it costs |
|---|---|---|
| Synchronous | Lower acknowledged-data loss and fresher followers | Write latency and sensitivity to slow replicas |
| Asynchronous | Fast writes and fault isolation | Lag and possible loss after leader failure |
| Multi-leader | Local writes in multiple regions | Conflict detection and resolution |
What happens if?
Leader fails after local write, before replication
If the client received success too early, the promoted follower may not contain the write. The system has acknowledged durability it cannot preserve.
What happens if?
A follower falls hours behind
Serving reads from it expands user-visible staleness. Rejoining may require a snapshot rather than replaying an unbounded log, and catch-up traffic can overload the leader.
Intermediate interview modeWhat is the difference between replication and consensus?Show answer
Replication copies state. Consensus makes participants agree on which decisions are authoritative and in what order despite failures. A replication topology may use consensus, but the concepts are not interchangeable.