How do Kafka consumer groups work?
A Kafka consumer group is a set of consumers that collaboratively consume messages from one or more topics. The core rule is that each partition in a topic is assigned to exactly one consumer within a group at any given time. This means a group achieves parallelism up to the number of partitions — adding more consumers than partitions leaves some consumers idle.
Group membership and partition assignment are coordinated by the Group Coordinator, a broker elected for that group. When a consumer joins or leaves, the coordinator triggers a rebalance to redistribute partitions. Each group independently tracks its own offsets, stored in the internal `__consumer_offsets` topic. This allows multiple groups to consume the same topic at different rates without interference — a common pattern for fan-out (e.g., one group for real-time processing, another for audit logging).
Offset commits are the mechanism by which a consumer records progress. With `enable.auto.commit=true`, offsets are committed on a timer, which creates at-least-once semantics with a window of potential reprocessing on crash. For stronger guarantees, manual commit (`commitSync` or `commitAsync`) lets consumers commit only after processing is confirmed — or after writing to a downstream system transactionally.
Consumer group state is visible via `kafka-consumer-groups.sh --describe`, which reports partition assignments, current offsets, log-end offsets, and lag per partition. Monitoring lag is the primary operational concern — sustained growing lag signals that consumer throughput is insufficient and scaling or optimization is needed.
A single consumer with `group.id` set to a unique value effectively acts as a broadcast consumer, receiving all partitions for itself — the standard pattern when you need every message on every instance (e.g., cache invalidation).
Explains one-partition-to-one-consumer assignment, mentions that offset tracking is per group, and understands that multiple groups can consume independently.
Covers partition assignment limits (consumers > partitions = idle consumers), offset commit semantics (auto vs. manual), and operational monitoring via consumer lag. Mentions the group coordinator's role in rebalancing.
Reading the answer is step one. Explaining it unprompted — under interview pressure — is what actually matters. Get AI-graded feedback on your answer with follow-up probes on your weak points.
Get Graded — Free Assessment