Overview
Each partition has a preferred replica: the first one in its replica list (for a list of 1,5,9, node 1 is preferred). When a broker restarts it becomes a follower for all its partitions, so leadership can end up unbalanced. By default the cluster restores leadership to the preferred replicas automatically (auto.leader.rebalance.enable=true, checked every leader.imbalance.check.interval.seconds). You can also run the election yourself with kafka-leader-election.sh. The design page says the aim is to balance leadership so that each node leads a proportional share of the partitions.
Key configuration
auto.leader.rebalance.enable=true — default
leader.imbalance.check.interval.seconds=300 — default
bin/kafka-leader-election.sh --bootstrap-server localhost:9092 --election-type preferred --all-topic-partitionsProduction tip
Check yourself
What does preferred leader election do?
Sources
- Basic Kafka operations (4.2 documentation) (opens in a new tab)
- Broker configs (4.2 documentation) (opens in a new tab)
- ZooKeeper to KRaft differences (4.2 documentation) (opens in a new tab)
- Design (4.2 documentation) (opens in a new tab)
Checked against Kafka 4.2 documentation on Oct 2026. Draft: not yet reviewed by a Kafka specialist. Releases move on, so confirm against the current documentation before you act on a number.