Hire Me
Interactive Demo

Kafka Consumer Group Rebalancing

6 partitions · Up to 4 consumers · Partition reassignment on join and leave Add or remove consumers to trigger rebalancing · Kill simulates unexpected failure
STABLE
Consumers
2
Partitions
6
Rebalances
0
Lag (simulated)
0
0.0sConsumer group initialised with 2 consumers — 6 partitions assigned.

About this demo

Kafka distributes partitions across all consumers in a consumer group. Each partition is owned by exactly one consumer at any time, ensuring ordered processing within a partition. When a consumer joins or leaves the group — whether gracefully (clean leave) or unexpectedly (kill / session timeout) — the group coordinator triggers a rebalance: all consumers stop consuming, return their partitions, and the coordinator redistributes them from scratch.

During a rebalance, no messages are consumed from any partition in the group — this is the rebalance pause. With the default eager rebalancing protocol all partitions are unassigned before redistribution. The newer cooperative rebalancing protocol (available since Kafka 2.4) only revokes and reassigns the subset of partitions that actually need to move, keeping consumption running on stable partitions. Balancing consumer count against partition count determines throughput: with fewer consumers than partitions each consumer handles multiple; with more consumers than partitions, some consumers sit idle.

Pattern: Consumer Group · Partition Assignment · Rebalancing Technology: Apache Kafka · Spring Boot · Spring Kafka · Java Read: Kafka Consumers Deep Dive →