liveBook · Manning

Group.id

As explained in Apache Kafka in Action

group.id is the Kafka consumer configuration property that identifies the consumer group to which a consumer belongs.

Suppose a price-update service and a sales-analytics service both need every price change. Give each service a different `group.id`: each consumer group reads the topic independently and keeps its own offsets. Give multiple instances of the same service the same `group.id` so they form one group and share the partitions. section 9.4.1 section 4.2.2

Within a group, at most one consumer reads a given partition at a time. This lets instances divide the work without losing the partition’s ordering guarantee. Consumers in the group write offsets to Kafka, allowing a stopped consumer to resume where the group left off. Kafka brokers help coordinate partition assignment among members. section 4.2.2 section 9.4.1

Start and inspect a price-monitoring group

Start a consumer with `kafka-console-consumer.sh --topic products.prices-offsets --bootstrap-server localhost:9092 --group products.prices.monitoring --from-beginning`. The `--group` option supplies the group ID. Inspect its position with `kafka-consumer-groups.sh --group products.prices.monitoring --describe --bootstrap-server localhost:9092`. The resulting per-partition rows show current offset, log end offset and lag. If new messages arrive while the consumer is stopped, lag grows; restarting the consumer lets it read those messages. section 9.3.2

Choose group IDs deliberately. Accidentally reusing another consumer’s ID can make the consumers share or overwrite offsets, causing messages to be consumed by the wrong service or producing processing inconsistencies. Do not confuse the group ID with `client.id`, which is useful for logging, metrics and tracking. section 9.3.2

How Apache Kafka in Action covers it

How deep it goes
Explains membership, partition assignment, offset continuity and the consequences of reusing an ID; stops short of application configuration code.
Examples
Uses price-change services, console consumers sharing a group ID, and a consumer-group command reporting partition offsets and lag.
What it assumes
Builds on topics, partitions and offsets while introducing group membership through a console-consumer example.
What you can do after
Operate/configure a consumer group with `--group`, inspect its offsets and lag, and avoid unintended group ID reuse.
How it connects
Connects consumer groups to partitions, offsets, lag, broker coordination and the Kafka Rebalance Protocol.

Also explained in

Compare how 2 books explain group.id →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Apache Kafka in Action. The section links point to the parts of the book it draws on.