What Is a Consumer Group?
A consumer group is a set of consumer instances sharing the same group.id that jointly consume a topic's partitions, with Kafka guaranteeing that each partition is assigned to exactly one consumer within the group at any given time. This lets you scale reads horizontally: adding more consumer instances (up to the number of partitions) increases parallel processing throughput, while multiple independent groups can each read the full topic independently for entirely different purposes.
Cricket analogy: Like an IPL team assigning exactly one fielder to cover each specific zone of the ground, so no two fielders chase the same ball; each partition has exactly one consumer within the group.
Rebalancing
When a consumer joins or leaves a group (including crashing, or being killed by exceeding max.poll.interval.ms), the group coordinator triggers a rebalance to redistribute partitions among the remaining members. The original 'eager' rebalance protocol revokes every partition from every consumer before reassigning them all, causing a brief full-group pause; the newer cooperative sticky assignor (partition.assignment.strategy=CooperativeStickyAssignor) instead only reassigns the specific partitions that need to move, letting unaffected consumers keep processing without interruption.
Cricket analogy: Like a captain reshuffling fielding positions the moment a substitute comes onto the field, redistributing zones among the eleven currently on the pitch.
Scaling and Static Membership
A consumer group can never usefully have more active consumers than the topic has partitions, since Kafka assigns each partition to exactly one consumer; extra consumers simply sit idle. For consumers that restart frequently (rolling deploys, pod rescheduling), setting group.instance.id enables static membership, letting a restarting consumer rejoin with its previous partition assignment intact within session.timeout.ms, avoiding an unnecessary rebalance for what is really just a brief, expected restart.
Cricket analogy: Like a team having only 11 fielding positions; a 12th player on the bench can't field simultaneously, just as a consumer group can't usefully have more consumers than partitions.
# consumer.properties for a scaled-out order-processing group
group.id=order-processing-service
group.instance.id=order-processing-pod-3
partition.assignment.strategy=org.apache.kafka.clients.consumer.CooperativeStickyAssignor
session.timeout.ms=45000
max.poll.interval.ms=300000
enable.auto.commit=falseStatic membership (group.instance.id) is especially valuable in Kubernetes deployments: a pod restart during a rolling update looks like a brief blip rather than a full group departure, so the coordinator waits for it to rejoin within session.timeout.ms instead of immediately triggering a disruptive rebalance.
- Within a consumer group, each partition is assigned to exactly one consumer at a time.
- Adding consumers beyond the partition count leaves the extras idle.
- Rebalancing redistributes partitions when group membership changes.
- The eager protocol revokes all partitions before reassigning; cooperative sticky minimizes disruption.
- max.poll.interval.ms exceeded causes the coordinator to treat a consumer as dead.
- group.instance.id enables static membership, avoiding rebalances on brief restarts.
- Different consumer groups reading the same topic operate completely independently.
Practice what you learned
1. Within a single consumer group, how many consumers can read a given partition at once?
2. What happens if a consumer group has more consumers than the topic has partitions?
3. What is the main advantage of the cooperative sticky assignor over the eager protocol?
4. What does group.instance.id enable?
5. What commonly triggers a rebalance?
Was this page helpful?
You May Also Like
Kafka Consumers Explained
How Kafka consumer clients poll for records, track their read position with offsets, and deserialize messages back into usable objects.
Kafka Producers Explained
How Kafka producer clients serialize, batch, and send records to topic partitions, and the configuration knobs that control durability and throughput.
Message Keys and Partitioning
How Kafka uses a record's key to choose a partition, why that determines per-key ordering, and the risks of custom partitioners and changing partition counts.
Related Reading
Related Study Notes in DevOps
Browse all study notesNginx Study Notes
DevOps · 30 topics
DevOpsAnsible Study Notes
DevOps · 30 topics
DevOpsAdvanced Kubernetes Study Notes
Kubernetes · 30 topics
DevOpsAdvanced Bash Scripting Study Notes
Bash · 30 topics
DevOpsDocker & Kubernetes Study Notes
YAML · 40 topics
DevOpsCI/CD Tools & Pipelines Study Notes
YAML · 37 topics