Introduction
Kafka's Partition Leader Election process is important in managing data reading and writing operations for each partition in a topic. A leader is one of the replicas of each partition, which coordinates all reading and writing requests. A leader failure or imbalance can affect the performance of the entire system, so leader re-election is an essential task for maintaining the availability of the cluster. Kafka Clusters by default elect leaders automatically, but you may need to elect leaders manually in certain situations.
To execute leader election, go to the Advanced > Leader Election menu.
Executing Leader Election
Modify the cluster's metadata to elect a new leader and ensure that all replicas of the partition recognize the new leader. You can perform leader election based on the selected Leader Election Type.
Leader Election Types
There are two types of leader election methods available.
1. Preferred Leader Election
This method elects a leader among the replicas in the ISR (In-Sync Replicas) list. The ISR is a set of replicas that have the most recent data, which ensures data consistency and durability.
2. Unclean Leader Election
This method allows the election of a leader also from replicas not in the ISR list. This, however, has the risk of data loss, so it should only be used in emergency situations where availability must be maintained.