Explain like I'm five · SRE

What is Replication?

Replication, told as a story about keeping the same guest log copied in several warehouses.

the log... it's all gonea fire in the warehouse, and the whole log is gone

A fire in the warehouse, and the whole log is gone.It only lived in one place, so there's nothing to recover.

only one placecan we trust just one place?keep it in one place, and if that place fails, it's gone

Keep it in one place, and if that place fails, it's gone.Betting everything on a single spot is risky.

LEADERFOLLOWER 1FOLLOWER 2the same log, copied into two or three warehousesif one burns down, the rest still have it

The same log, copied into two or three warehouses.If one burns down, the rest still have it.

One leader warehouseonly it handles writing
The rest just copythey handle reading
Copying takes a momentcalled replication lag
If the leader breaksa follower becomes the new leader
LEADER (writes)FOLLOWER (reads)new entryarriving takes a short moment (replication lag)LEADER DOWN?a followerbecomes leaderthe leader handles writes, the rest just copy

The leader handles writes, the rest just copy.It takes a moment to arrive, and if the leader fails, a follower takes over.

did it just change?while copying, you might get a slightly stale answerI'M THE LEADER!I'M THE LEADER!two warehouses both claiming to be the leader is a problem

While copying, you might get a slightly stale answer.And two warehouses both insisting they're the leader is a real problem.

In one breath

Replication = keeping the same log copied across several warehouses. The leader handles writes and the rest just copy, so the service survives even if one warehouse fails.

Copying data across multiple servers. There's a leader and followers; synchronous replication updates immediately, asynchronous replication catches up a bit later (consistency). When a follower takes over from a failed leader, that's called failover.

When grown-ups say it

Replication
Keeping the same log in several warehouses. The service keeps running even if one warehouse fails.
Leader/follower
The warehouse that writes, and the ones that just copy. There's one leader, but there can be many followers.
Replication lag
The short time it takes to copy over. During that gap a follower may answer with slightly old data.
Read replica
A follower dedicated to reads. It takes read load off the leader.
Sync / async replication
Whether copying happens instantly or a bit later. Instant is safer but slower.
Multi-region
Putting a follower in a whole different city. It survives even if one whole city has trouble.
Eventual consistency
Getting a slightly different answer while copying is still in progress. Given enough time, every copy agrees.
Failover
A follower stepping up to be leader when the leader fails. Deciding who becomes the new leader is a vote. → control rooms raising hands to decide
Next story
Control Rooms Raising Hands to Decide →
Want another term as a picture book? Request →