Advanced · How a group of servers agrees on one truth.
Consensus (Raft)
Distributed databases need one leader to order writes. When it dies, the rest must elect a new one without ever ending up with two. Raft does it with heartbeats, terms and majorities.
Try this
Run each experiment in the simulator above, then tick it off.
Key ideas
Heartbeats
The leader pings followers. Silence past a random timeout triggers an election.
Majority (quorum)
A leader needs votes from a majority, and a write commits once a majority stores it. Two majorities always overlap, so there can't be two leaders in one term.
Under half alive means stop
Refusing writes beats corrupting data.
In your Pabbly workflows
You won't implement this, but it explains why managed databases come in 3 or 5 nodes (not 2 or 4), and why some services go read-only during an outage instead of losing your data.
Check yourself
0/2Get every question right to mark this lab done. Wrong answers let you try again.
Q1. A 5-node cluster can lose how many nodes and still accept writes?
A majority of 5 is 3. Lose 2 and 3 remain; lose 3 and there's no majority left.
Q2. Why are election timeouts randomized?
With identical timeouts every follower would stand at once, vote for itself, and nobody would win.
Lab complete
Marked done on this device. On to the next one.
Watch next
Searches for “raft consensus” on the channels worth your time.