liveBook · Manning

Leader rebalancing

As explained in Apache Kafka in Action

Leader rebalancing is the redistribution of Kafka partition leadership to restore preferred leader assignments or balance broker load.

Leader rebalancing restores a partition’s preferred leader after a broker returns or leadership has shifted. A returning broker first synchronizes as an in-sync follower; it may later reclaim leadership automatically or require a manual election. section 5.3

Use the following operational sequence:

  • Confirm that the recovered broker has rejoined the ISR and that replicas are synchronized. section 5.3
  • Trigger preferred elections with kafka-leader-election.sh when automatic rebalancing is not configured or has not occurred. section 5.3
  • Avoid unclean elections except in an extreme emergency, because an out-of-sync replica may lack messages and cause data loss. section 5.3

Restoring a preferred leader

For products.prices.changelog.replication-3, Broker 3 returns and becomes an ISR follower for Partition 1. Running kafka-leader-election.sh with --election-type=preferred and --all-topic-partitions moves leadership back to Broker 3.

How Apache Kafka in Action covers it

How deep it goes
Explains recovery, ISR synchronization, automatic timing, manual election, and unclean-election risk without detailing controller internals.
Examples
Demonstrates Broker 3 recovering, rejoining the ISR, and reclaiming Partition 1 through a preferred election.
What it assumes
Assumes familiarity with Kafka brokers, partitions, replicas, leaders, followers, and ISR membership.
What you can do after
Operate leader restoration with kafka-leader-election.sh and distinguish safe preferred elections from risky unclean elections.
How it connects
Connects partition leadership with replication, replicas, in-sync replicas, broker recovery, and leader election.

This explainer was generated by Manning's knowledge graph from the text of Apache Kafka in Action. The section links point to the parts of the book it draws on.