Leader election is the procedure by which a group of distributed nodes agrees that one of them will act as the coordinator, often called the leader or primary. A single coordinator simplifies the system: it can decide the order of operations, drive replication, and serve as the one writer, which avoids the conflicts that arise when many nodes try to act authoritatively at once.
The Raft algorithm of Diego Ongaro and John Ousterhout puts leader election at the center of its design. Raft divides time into terms; at the start of each term, nodes hold an election in which a candidate that receives votes from a majority of the cluster becomes leader for that term. Because every term has at most one majority of votes, Raft guarantees at most one leader per term, and randomized election timeouts keep the nodes from repeatedly splitting the vote.
Election is also a recovery mechanism. When a leader crashes or becomes unreachable, the remaining nodes notice the absence of its regular messages and start a new term to elect a replacement, allowing the system to keep making progress after a failure.
The same idea appears throughout distributed infrastructure. Lamport’s multi-Paxos uses a distinguished proposer that plays a leader-like role to drive the log forward, and coordination services such as ZooKeeper and cluster managers such as Kubernetes rely on electing a single coordinator to keep their replicated state consistent.