Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

kafka partition rebalancing (assignment) is taking too much time

We are using kafka cluster with 3 servers, all of them are having zookeeper as well. we have 7 topics each with 6 partitions. We have 3 java consumers for each topic. When I start consumer it takes almost 3-5 min to assign partitions to consumers. The same behavior is encountered when we stop one of the consumer and start is again. How can I control or reduce it?

Please note, I am using kafka 0.9, with new consumer

I have added below properties in server.properties of each kafka

auto.leader.rebalance.enable=true
leader.imbalance.check.interval.seconds=10

Let me know if you need more information. Thanks

like image 799
Sunny Gupta Avatar asked Nov 05 '25 16:11

Sunny Gupta


1 Answers

Check the value your consumer is using for 'session.timeout.ms'.

The default is 30 seconds and the co-ordination won't trigger a rebalance until this time has passed E.g. no heartbeat for 30 seconds.

The danger in making this lower is if you take too long to process the messages a rebalance might occur because the co-ordinator will think your consumer is dead.

like image 188
Michael Freeman Avatar answered Nov 07 '25 11:11

Michael Freeman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!