A failure detector tells a node when to suspect its leader has failed. Raft's election algorithm describes what happens next: the follower becomes a candidate, starts a new term (an election round), votes for itself, and asks its peers for their votes.

Each node votes for at most one candidate per term. In this five-node cluster, a candidate needs three votes, including its own. Two candidates cannot both win a majority in the same term because their majorities would need to share a voter.

Loading 3D demo…

Loading 3D scene…

  • A · follower · term 1 · voted for B
  • B · leader · term 1 · voted for B
  • C · follower · term 1 · voted for B
  • D · follower · term 1 · voted for B
  • E · follower · term 1 · voted for B

B leads term 1. Crash the leader to follow the election.

When a leader crashes and rejoins the cluster, it starts as a follower.