Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to load balance the Kafka Leadership?

Tags:

apache-kafka

My kafka version is kafka_2.9.2-0.8.1.1. I have two brokers in the cluster, 4 topics and each topic has 4 partitions.

When I run

sh kafka-topics.sh --describe --zookeeper rhost:2181

for all the topics/partitions, I see broker 1 as Leader.

How can I load balance the leader?

For example, for topic 1 and topic 2 have broker 1 as leader and for topic 3 and topic 4 have broker 2 as leader.

like image 557
james007 Avatar asked Oct 21 '14 07:10

james007


1 Answers

The partitions should be automatically rebalanced, since the default value of the broker configuration parameter auto.leader.rebalance.enable is true. (see documentation)

However, by default this rebalance occurs every 5 minutes, as defined by the leader.imbalance.check.interval.seconds parameter. If you wish this to occur more frequently, you will have to modify this parameter.

like image 107
Régis B. Avatar answered Sep 18 '22 15:09

Régis B.