100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace
Kafka

Consumer Groups

How Kafka consumer groups distribute partitions across cooperating consumers to scale reads horizontally, and how rebalancing keeps that assignment correct.

Producers & ConsumersIntermediate10 min readJul 10, 2026
Analogies

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.

properties
# 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=false

Static 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

Was this page helpful?

Topics covered

#Kafka#ApacheKafkaStudyNotes#DevOps#ConsumerGroups#Consumer#Groups#Group#Rebalancing#StudyNotes#SkillVeris