Raft: Leader Election and Log Replication
One consensus algorithm end to end. A term-numbered election picks a single leader, the leader appends entries to its followers, and an entry is committed once a majority holds it. Every rule in the protocol exists to stop one specific bad history.
What a learner can do afterwards
- Walk an election through a term change and say why two leaders cannot both win one term
- Say what commitment means here and why a majority is the threshold
- Take one rule of the protocol and name the history it prevents
1 · Read
Raft numbers every election with a term. A majority is more than half the nodes. Each node votes once per term, so two candidates cannot both win one term: two majorities share a voter, and that voter only votes once. The winner becomes the single leader. If votes split and nobody wins, nodes wait a random time and start the next term, so Raft gives up a guaranteed finish.
The leader takes client writes, appends them to its log, and sends each entry to its followers. An entry the leader added in its own term is committed once a majority holds it. If the leader fails, the new leader is elected and every committed entry survives, because any majority includes a copy.
Every rule blocks one specific bad history. Voting once per term blocks two leaders deciding differently. Requiring an up-to-date log for new leaders blocks the loss of committed entries.
Walk any failure by asking one question: did the leader that added the entry get it onto a majority during its own term? If yes, the entry is committed and survives. If no, it may be gone.
One leader per term appends entries, majorities commit them, and committed means surviving.
Lesson, quiz and flashcard text written for this dataset and revised in the P25 source pass.
2 · Watch
Take it off screen
Where it sits
8 questions wait behind this lesson, each with its answer explained. Every answer feeds the sky: stars light as they are learned, and dim when it is time to come back.