SteelReed

Search

Search posts, questions…

Messaging & KafkaQuestion 7 / 21

Junior

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.

Topic: 4 partitionsGroup A: 2 consumersGroup B: 1 consumerC1 reads P0, P1C2 reads P2, P3C3 reads P0–P3

3 points to say:

  1. Within a group, one consumer per partition; consumers beyond the partition count sit idle.
  2. Different groups read independently, each with its own offsets; one group.id per application.
  3. 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.