Why pick a leader
When many nodes must agree on who does a job, having every node act at once causes conflicts. Instead the cluster elects a single leader that owns the decisions, while the others become followers that replicate state and wait.
How the roles work
- The leader accepts writes, sequences them, and pushes updates to followers.
- A follower applies what the leader sends and answers reads from its copy.
- If the leader stops sending heartbeats, a follower notices the silence and starts a new election.
This keeps a clear single source of truth. Only one node decides ordering, so there is no tug of war over who wrote what first.
The handoff
A leader proves it is alive by sending periodic heartbeats. When followers miss several in a row, they assume the leader failed and one of them campaigns to become the next leader. The cluster briefly has no leader during this window, so writes pause until a new one wins.
Key idea
Leader follower coordination funnels all decisions through one elected node so ordering stays consistent, while heartbeats let followers detect failure and promote a replacement.