Skip to content

CONCEPT Cited by 1 source

Consumer group

Definition

A consumer group in Apache Kafka is a set of consumers that cooperatively divide the partitions of a topic among themselves. Group membership + partition-to-consumer assignment are coordinated through a broker — consumers "synchronize each other through talking to the broker — they are not connected to one another" (Kozlovski, sources/2024-05-09-highscalability-kafka-101).

Invariants

  • Partition exclusivity within a group — no two consumers in the same group read from the same partition (see patterns/consumer-group-partition-exclusivity). This is what preserves in-partition record ordering end-to-end: since a partition is consumed by exactly one group member, and records within a partition are ordered, the group member observes records in order.
  • Progress persisted — a consumer group persists how far it has consumed each partition (the committed offset) in a special internal topic __consumer_offsets.
  • Horizontal scale limit — a group can have at most as many actively-consuming members as the topic has partitions. Extra members sit idle.
  • Multi-group fan-out — the same topic can have many consumer groups simultaneously, each at its own position. This is the producer/consumer decoupling that let Kafka beat classical message buses.

Group Coordinator

Each consumer group has a Group Coordinator, which is the broker that leads the partition of __consumer_offsets the group's offsets are stored in:

"The broker that is the leader of the partition acts as the so-called Group Coordinator for that consumer group, and it is this Coordinator that is responsible for maintaining the consumer group membership and liveliness." (Source: sources/2024-05-09-highscalability-kafka-101)

The Group Coordinator:

  • Accepts join / leave messages from group members.
  • Runs the rebalance protocol when membership changes, reassigning partitions across current members.
  • Receives offset commits and persists them to __consumer_offsets.

Where consumer groups show up in the ecosystem

Seen in

Last updated · 319 distilled / 1,201 read