Monedula

Kafka consumer config

auto.offset.reset: earliest vs latest

Consumer config · default latest · Apache Kafka 4.3

auto.offset.reset decides where a consumer starts reading when its group has no committed offset for a partition, or the committed offset no longer exists in the log. latest (the default) starts at the end and reads only records produced from then on; earliest starts at the oldest record still retained and reads the whole backlog. It does nothing for a group that already has a valid committed offset.

Config
auto.offset.reset (consumer)
Default
latest
Valid values
latest, earliest, by_duration:<ISO 8601 duration> (such as by_duration:PT1H), none
Reference
Apache Kafka documentation for auto.offset.reset
g-latest starts at the END · g-earliest at the START. Both groups just joined. g-latest (reset=latest) seeked to the END - position 3, so it will read none of O1-O3. g-earliest (reset=earliest) seeked to the START - position 0, about to replay all three. Open this step in the full playground

Values

What it does

A consumer group resumes each partition from its committed offset. auto.offset.reset is only the fallback for the two cases where that offset is missing or useless: a group that has never committed for the partition (a new group, a newly added partition, or a group whose offsets expired after offsets.retention.minutes, 7 days by default, with no members), and a committed offset that retention has already deleted, which the broker answers with OFFSET_OUT_OF_RANGE. Restarting a consumer, deploying a new version or rebalancing does not apply it as long as the group still has a valid committed offset, so changing the setting on an existing group usually changes nothing.

The trade-off

earliest never skips data, but a new group reads the whole retained log first, which can be days of records to process before it catches up, and a group recovering from an out-of-range offset reprocesses whatever is left. latest starts instantly and never replays, but it silently skips everything produced before the group first joined, and when partitions are added to a topic, records producers write to a new partition before the group is assigned it are skipped too. none makes the choice explicit at the cost of handling the exception yourself.

Advice

See it in the simulator

Related configs

All Kafka configs