...
JIRA: KAFKA-5319
Released:
Motivation
I want think kafka need to add a tool to make amounts of replicas and leaders on every brokers balanced.Current kafka server does not provide a function to make cluster balance.When we use console command to create a topic without 'replicaAssignmentOpt' ,kafka server assigns replicas by a "replicaAssignment" function . The function spread the replicas evenly among brokers to make cluster balanced.It can not make sure the cluster is balanced.Even though it is balanced,the balanced state will be destroyed.Example:
1.Adding some new broker to current kafka cluster.There is nothing in a new broker.The amounts of replicas and leaders in new brokers are always fewer than old ones. The cluster is imbalanced any more.
2.Using ReassignPartitionsCommand will change the replica and leader balance of cluster.
...
Some one want to assign replicas of 3 partitions to broker 1,2,3.The one is accustomed one was accustomed to write AR in ascending order.Kafka server choose a PreferredReplicaLeader which be put at the first position of the AR to make leader balance .If all leaders are the PreferredReplicaLeader of AR ,kafka server thinks leaders in cluster is balanced.In above case,kafka server thinks it is balance when all leaders are replica 1.In fact the leader balance is not good at that time.
...
show-cluster-state This command print out current cluster balance state.We can use it to learn whether or not the cluster need to be balanced
leader-balance This command let amounts of leaders of every brokers make balanced
replica-rebalancebalance This command let amounts of replicas and leaders of every brokers make balanced
Public Interfaces
...