Search DistillSys

Find a concept

Type at least two characters to search lessons, designs, papers, and interview prep.

Replicationfundamental6 min read

Replication

Copy state across machines without confusing more copies with stronger correctness.

2–5 minute refresher
Mental model

Accept change → order it → copy it → confirm it → repair lag

30second
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

ChoiceWhat you gainWhat it costs
SynchronousLower acknowledged-data loss and fresher followersWrite latency and sensitivity to slow replicas
AsynchronousFast writes and fault isolationLag and possible loss after leader failure
Multi-leaderLocal writes in multiple regionsConflict 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.
#replication#leader-follower#lag#durability