Implement Raft Leader Election

terms, votes and majority quorum

Challenge 4 of Coordination & ConsensusAdvanced~60 min

Elect a single leader in a cluster where nodes crash and messages drop, the heart of the Raft consensus algorithm. Implement the election: a node bumps its term and becomes a candidate, peers grant at most one vote per term, a candidate that wins a majority becomes leader, and any node that sees a newer term immediately steps down. The mechanism that keeps etcd, Consul, and CockroachDB consistent.

4 steps

  1. 1Terms and Candidacy
  2. 2Granting Votes
  3. 3Counting a Majority
  4. 4Becoming Leader, and Stepping Down
Start step 1