Kafka enable.auto.commit vs enable.auto.offset.store
Codemia Knowledge Hub ·
enable.auto.commit decides whether the consumer periodically commits offsets to Kafka in the background. enable.auto.offset.store (a librdkafka setting, used by clients such as confluent-kafka) decides which offsets are eligible for that commit: when it is true, the default, an offset is stored automatically as soon as a message is handed to your application; when it is false, only offsets you store yourself after processing get committed.
What an offset is
An offset uniquely identifies a record within a partition and marks its position in the immutable log. Committed offsets let a consumer resume from where it stopped after a failure or restart.
enable.auto.commit
With enable.auto.commit=true, the consumer commits offsets automatically on an interval, writing them to the __consumer_offsets topic. After a restart it resumes from the last committed offset.
Example configuration:
Here offsets are committed every 5000 milliseconds. A smaller interval reduces how many messages are re-processed after a failure, but adds commit overhead. Auto-commit does not guarantee that each message is processed only once: messages handled after the last commit are delivered again after a crash.
enable.auto.offset.store
Setting enable.auto.offset.store=false stops the client from storing offsets automatically when messages are read. Your application then stores the offset explicitly once processing succeeds (for example with store_offsets() in confluent-kafka Python), and the background auto-commit commits only those stored offsets. Alternatively, with auto-commit also off, you commit manually.
Example scenario: each message's result must be written to a database, and the offset should advance only if that write succeeds. If offsets advance automatically on read, an error between consuming the message and writing the result can lose or duplicate data. With enable.auto.offset.store=false, you store the offset only after the database write.
| Configuration Key | Value Options | Purpose | Typical Use Case |
enable.auto.commit | true / false | Enable or disable auto-commit of offsets | For simpler use cases without strict transaction requirements |
enable.auto.offset.store | true / false | Enable or disable auto-storage of offsets when read | To manage offsets manually in complex processing scenarios |
Combining the two settings
- Auto-commit on, auto offset store off: the common pattern for at-least-once processing with librdkafka. You store each offset after processing the message, and the background commit sends the stored offsets to Kafka. Forgetting to store offsets means nothing is committed.
- Both off: full manual control. You commit offsets yourself, which suits systems with strict transactional requirements.
Choosing and testing an offset strategy
- Decide on the processing guarantee you need (at-most-once, at-least-once, exactly-once) before choosing the configuration.
- Test consumer failover to confirm behavior under failure, especially with manual offset control.
- Monitor offset lag and consumer groups for abnormalities, whatever the configuration.
Related reading
- Kafka offsetcommit request with high level consumer API
- Kafka on AWS ECS, how to handle advertised.host without known instance?
- kafka on kubernetes cannot produce/consume topics (ClosedChannelException, ErrorLoggingCallback)
- Kafka on kubernetes cluster with Istio
- Kafka Streams - Processor context commit
- Kafka Streams error - Offset commit failed on partition, request timed out
- Kafka on Kubernetes multi-node
- Kafka on Masstransit
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.