100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace
Big Data & Distributed Computing
30 minintermediate

Consumer Groups and Offset Management

Consumer groups are Kafka's mechanism for scalable, fault-tolerant message consumption: multiple consumer instances share a group ID and partitions are divided among them, so throughput scales with consumer count up to the partition limit. When a consumer joins or leaves the group, Kafka triggers a rebalance that redistributes partition assignments across all live members. Understanding rebalances and how to handle them gracefully is the most operationally important skill for Kafka consumer engineering, because rebalances pause message processing for the entire group, not just the consumer that triggered the rebalance.

Offset management — tracking which messages a consumer has processed — is the state management problem at the heart of Kafka consumer design. Kafka stores committed offsets in an internal topic (`__consumer_offsets`) keyed by group ID and partition. The consumer's position is the next offset to be fetched; the committed offset is the last durably recorded as processed. Consumer lag — the difference between the topic's high-water mark and the committed offset — is the primary health metric, measuring how far behind the consumer is relative to the producer.

Analogy🏏Cricket
🏏 Think of it like cricket: Imagine the DRS review system deployed across three independent video-review centres in Mumbai, Chennai, and London, each holding a copy of the ball-tracking data. A CAP partition is a network outage that cuts communication between them. A CP system says: if the centres cannot synchronise, no review decision is issued — no player walks until the system is restored. Consistency is guaranteed; availability is sacrificed. An AP system says: each centre issues its own decision based on its local data, even if that means Mumbai says out and London says not out — reviews continue but different centres may give different verdicts. Partition tolerance is non-negotiable because the network always has the possibility of failing; the choice is whether umpires wait for consensus or proceed with local data.
Lesson 21 of 35
0% complete