LightMySky

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.

No account needed. Progress saves in this browser.

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. 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.

Try it together

The leader takes client writes, appends them to its log, and sends each entry to its followers. An entry 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.

Good to know

Walk any failure by asking one question: was the entry on a majority. If yes, it survives. If no, it may be gone.

One leader per term appends entries, majorities commit them, and committed means surviving.

2 · Watch

Take it off screen

Print a worksheetA4 with an answer key page for grown-ups. No screen, no internet.

Where it sits

Then practise

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.

Spotted a problem on this page? Tell us
Raft: Leader Election and Log Replication · Computing, ages 22 to 23 · LightMySky