Practice this topic in a realistic system design interview
Many distributed systems are easier to reason about when one node is in charge of a specific kind of work. That node is called the leader.
Leader election is the process of choosing that node automatically, and choosing a replacement when it fails.
A leader might accept writes for a replicated database, assign jobs to workers, own a shard, run a controller loop, coordinate failover, or order changes to shared metadata.
The hard part is not picking a leader on a sunny day. The hard part is staying safe when machines crash, the network splits, clocks drift, or an old leader keeps running after losing contact with the rest of the cluster.
Not every node has to learn about the new leader immediately. But only a valid leader should be allowed to make decisions that matter. This chapter explains how leader election works and how systems avoid the worst case: two nodes acting as leader for the same thing.