Kafka consumer group offset retention (offsets.retention.minutes)
Codemia Knowledge Hub ·
Kafka keeps a consumer group's committed offsets for at least offsets.retention.minutes, which defaults to 10080 minutes (one week) since Kafka 2.0. Since Kafka 2.1 (KIP-211) the clock starts when the group becomes empty, so an active group keeps its offsets. Once the group has had no members for that long, its offsets may be discarded and it can no longer resume from where it left off.
What a consumer group offset is
A consumer group is a set of consumers that jointly read one or more topics, with each consumer reading specific partitions. The offset is a number that tracks the last record a consumer read in a given partition. Committed offsets let the group pick up where it stopped after a consumer failure or rebalance.
Why retention matters
Retained offsets let a group resume consumption after a period of inactivity or a restart. Retention mostly matters for consumers that process data infrequently, or that are down for maintenance or upgrades.
offsets.retention.minutes and offsets.retention.check.interval.ms
offsets.retention.minutes sets the minimum period, in minutes, to retain committed offsets. The default of 10080 can be changed to fit business requirements or operational policies.
offsets.retention.check.interval.ms controls how often Kafka checks for stale offsets to purge. A shorter interval cleans up offsets faster but may add load on the brokers.
| Parameter | Default Value | Description |
offsets.retention.minutes | 10080 minutes | Minimum time to retain the committed offsets. |
offsets.retention.check.interval.ms | 600000 (10 minutes) | Frequency at which Kafka checks for old offsets to clean. |
Example configuration:
Where offsets are stored
Consumers commit offsets to an internal Kafka topic named __consumer_offsets, which Kafka manages itself. Kafka periodically checks this data against the retention configuration and removes entries that exceed the threshold.
What goes wrong when retention is misconfigured
- Data re-processing: if offsets are cleaned up too early, consumers can start from an earlier offset and process messages again.
- Loss of state information: stateful applications that rely on offsets for context or processing order can be significantly disrupted.
- Storage cost: very long retention rarely affects consumers, but it increases storage on the brokers, which can indirectly affect performance.
Choosing a retention period
- Match consumption patterns: infrequent consumers may need longer retention.
- Monitor and adjust: revisit the settings as the scale or shape of consumption changes.
- Balance: weigh retention duration against broker resource usage.
Related reading
- Kafka consumer group script to see all consumer group not working
- Kafka consumer groups and partitions
- Kafka consumer groups deletion
- Kafka Consumer hanging at .hasNext in java
- Kafka Consumer in C++
- Kafka consumer manual offset commit
- Kafka Consumer How to programatically consume from specific offset in Go Sarama
- Kafka Consumer How to start consuming from the last message in Python
System design interview problems on this topic
- Design a Distributed Messaging System: solution and walkthrough
- Design a Log Collection and Analysis System: solution and walkthrough
- Design an Ad Click Aggregation System: solution and walkthrough
- Design a Webhook Notification Service: solution and walkthrough

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseSystem Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.