A consumer group divides a topic’s partitions among its consumers. When a consumer joins or fails, or the topic’s partitions change, the group needs a new distribution. That redistribution is a rebalance. Kafka brokers coordinate the group, while consumers take part in deciding who receives each partition. section 9.4.1 section 9.5
Each group has a broker acting as its group coordinator. Consumers send join requests to that coordinator; during a rebalance, one consumer acts as group leader, determines the partition assignments, and communicates them to the coordinator. The other consumers follow those assignments. Kafka also uses the rebalance protocol to distribute resources such as Kafka Streams and Kafka Connect tasks. section 9.4.1 section 9.4.2
Choosing an assignment strategy
Suppose three consumers subscribe to two topics with two partitions each. With the default Range Assignor, one consumer gets partition 0 of both topics, another gets partition 1 of both, and the third gets none. Keeping matching partitions together can help when data from the two topics must be joined, but it leaves a consumer idle. When cross-topic joins are not needed, Round Robin Assignor spreads partitions more evenly. Configure the choice with partition.assignment.strategy, and use the same strategy throughout the group; mismatched strategies can cause unpredictable assignment changes. section 9.4.2 section 9.5
Figure 9.5 By default, partitions in a consumer group are assigned in such a way that the same partition across different topics is always consumed by the same consumer. While this may not be the most resource-efficient allocation, it allows us to easily perform joins across multiple topics.
Compare the matching cross-topic partitions with the idle consumer in the Range Assignor example. section 9.4.2
A rebalance can interrupt consumption, depending on the assignment strategy. Cooperative Sticky Assignor reduces that disruption by moving partitions in two rounds: consumers first release partitions that must move, then the unassigned partitions are allocated. Other consumers can continue consuming during the process. Static membership offers another way to reduce rebalance frequency, using unique group instance IDs and longer session timeouts. section 9.4.2 section 9.5
Figure 9.7 The Cooperative Sticky Assignor avoids stopping the world and rebalances by replacing a single rebalance by two consecutive ones. During the first rebalance, consumers are asked to let go of the partitions that should be moved to another consumer; in the second rebalance, the now dangling partitions are assigned to the consumers.
Trace the release and reassignment rounds that avoid stopping the whole group. section 9.4.2
Watch for rebalances caused by slow consumers. If processing delays polls beyond max.poll.interval.ms, a consumer can be considered inactive and trigger a group-wide rebalance. Monitor time between polls and time since the last poll alongside rebalance counts, failures, and latency. Some rebalancing is normal; rising frequency or duration deserves investigation, especially when consumption pauses during reassignment. section 15.3.3


