Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kafka consumer rebalancing condition

What if I create a consumer C1 with group consumerGroup to read data from topic A. And some time later create consumer C2, in same group, to read data from topic B.

Will creation of consumer C2 trigger rebalance? As a more general question, when kafka will perform rebalance?

like image 577
f1sherox Avatar asked Oct 27 '25 15:10

f1sherox


1 Answers

Each time a new consumer joins the group or a consumer leaved the group (actively by calling close() or via timeout) a rebalance will be triggered.

Furthermore, if you subscribe to a topic that is not created yet, a rebalance will be triggered after the topic got created. Same, if a topic you subscribed to gets deleted. Also if the number of partitions for any subscribed topics get changed. Last but not least, if you subscribe via pattern, if a new topic matches the pattern or a matching topic gets deleted or if the number of partitions get changed for any matching topic, rebalance will happen.

See https://cwiki.apache.org/confluence/display/KAFKA/Kafka+0.9+Consumer+Rewrite+Design

like image 81
Matthias J. Sax Avatar answered Oct 29 '25 06:10

Matthias J. Sax