Many distributed algorithms need a leader. Election algorithms pick one when the current leader dies. Three classic approaches, each with tradeoffs.
Bully algorithm
Node with highest ID wins. Any node detects leader failure → sends ELECTION to higher IDs. Anyone alive with higher ID responds + starts own election.
Bully algorithm
Node with highest ID wins. Any node detects leader failure → sends ELECTION to higher IDs. Anyone alive with higher ID responds + starts own election.
Ring algorithm
Nodes arranged in logical ring. Election token passed around. Each node adds its ID. Highest ID at token completion wins.
Raft election
Randomized timeouts (150-300ms). First node to time out becomes candidate + requests votes. Majority wins. Randomization prevents most contested elections.
Split brain risk
Bully + Ring can elect two leaders during network partition. Raft's majority quorum prevents it — one partition has majority, other doesn't.
Practical choice
Raft dominates modern systems. Bully + Ring appear in older systems (Zookeeper, some HA clusters) but Raft's understandability wins.