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.