QamoosTech
Architecture & DesignReliabilityIntermediate

Leader Election

PronunciationLEE-der ih-LEK-shun

Definition

Leader election is how a group of nodes picks exactly one of them to coordinate work, and picks a new one automatically if the leader fails.

Where you hear it

In etcd, ZooKeeper, Kafka and database clusters, and when a scheduled job must run on only one instance.

Examples

  • The followers elected a new leader after the old one stopped sending heartbeats.
  • Only the leader runs the nightly cleanup job.
  • The cluster elects a new leader within seconds when the old one crashes.

Common mistake

Letting two nodes both believe they are the leader (split brain). A quorum rule prevents this.

Don't confuse with

A load balancer, which spreads requests across many equal nodes. A leader is one node with a special role.

Say it at work

  • In a meeting or chatWho is the current leader?
  • In an email or ticketA leader election takes a few seconds.