How do Kafka consumer groups work, and when does a rebalance happen?
Short answer
Consumers with the same group.id split the partitions: each partition goes to one consumer in the group, so useful consumers are ≤ the partition count. A rebalance happens when members join/leave, are considered dead, or the partition count/subscription changes.
3 points to say:
- Within a group, one consumer per partition; consumers beyond the partition count sit idle.
- Different groups read independently, each with its own offsets; one
group.idper application. - Rebalance on join/leave, lost heartbeat, exceeding
max.poll.interval.ms, or a partition count change; eager stops the whole group, cooperative/KIP-848 moves only what is needed.
Keep reading the deep dive
Create a free account to read the full explanation and follow-up questions, mark questions as studied and review them on a schedule.