What does auto.offset.reset do in Kafka?
`auto.offset.reset` is a consumer configuration that determines where Kafka begins reading messages when a consumer group has no committed offset for a partition — or when the committed offset is out of range (e.g., it was deleted due to log retention). The two primary values are `earliest` and `latest`.
With `earliest`, the consumer starts from the oldest available message on the partition — the beginning of the retained log. This is appropriate for new consumers that need to process all historical data, such as a freshly deployed service reading an event log to rebuild state. With `latest`, the consumer starts from the current end of the log, receiving only messages produced after the consumer first started. This is typically used for real-time feeds where historical data is irrelevant.
The third option, `none`, causes the consumer to throw an exception if no committed offset is found, forcing you to handle the bootstrap case explicitly in code. It is rarely used in production but can be valuable in strict operational environments where starting from an unexpected offset would be a bug.
Critically, `auto.offset.reset` only applies when there is no valid committed offset for the group. If a committed offset exists — even a stale one — Kafka uses it and ignores this setting entirely. This trips up engineers who reset a consumer group or deploy a new group expecting a specific behavior but forget that existing committed offsets take precedence.
A common production scenario where this matters: your retention policy deletes log segments, and a lagging consumer's last committed offset no longer exists in the log. The consumer's offset is now out of range. With `earliest`, it resets to the beginning of available data (potential reprocessing of recent messages); with `latest`, it skips ahead to current (potential data loss). Knowing which is appropriate for your use case is an architectural decision, not just a configuration detail.
Correctly defines earliest and latest behavior, and knows the setting only applies when no valid committed offset exists.
Explains the out-of-range offset scenario (log retention deleting committed offsets), mentions the 'none' option and its use case, and articulates when each value is appropriate in real system designs.
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