Why Raft elects a leader
Raft was designed to be understandable. Every node is a follower, candidate, or leader, and time is divided into numbered terms. Each term has at most one leader, and all client writes flow through that leader.
Timeouts trigger elections
A follower expects regular heartbeats from the leader. If it hears nothing before its election timeout expires, it becomes a candidate, increments the term, votes for itself, and asks others for votes.
- Each follower grants at most one vote per term, first come first served.
- A candidate that collects a majority of votes becomes leader and starts sending heartbeats.
- If no one wins, the term ends in a split vote and a new election begins.
Breaking split votes
To avoid repeated ties, each node uses a randomized election timeout. Because nodes wake at different moments, one usually starts its campaign first and gathers a majority before others time out. This simple randomization makes split votes rare and self correcting.
Key idea
Raft elects one leader per term using randomized timeouts and majority voting, so split votes are rare and resolve quickly.