Replication
Medium+14 XPWatch one write land on the leader and ripple out to every follower copy.
No visualization loaded.
Watch
—
Press Run to begin.
Replication means keeping COPIES of your database on several machines. Press Run and watch a write go to the one 'leader' copy, then get copied out to the 'followers' — until every copy agrees.
▸Why keep copies at all?
Two reasons. Safety: if one machine dies, the data still lives on the others. And speed: many copies can answer READ requests at the same time, so you can serve a huge crowd.
▸Why must writes go to ONE leader?
So the copies don't disagree. If two machines both accepted writes, they could end up with different values for the same thing. Funneling every write through one leader keeps a single source of truth, which then copies out to everyone.
▸What's 'replication lag'?
The tiny delay between the leader saving a change and the followers getting the copy. For a moment, a follower might still show the OLD value. Usually that's fine; but if you read from a follower right after writing, you might not see your own change yet.
▸What if the leader itself dies?
Then one of the followers is promoted to be the new leader, and writes go there instead. That's why copies are so valuable — the system survives losing any single machine.