CCDAK practice question 24 of 25

A consumer has auto.offset.reset=latest, and the topic partition currently has data for offsets going from 45 to 2311. The consumer group never committed offsets for the topic before. Where will the consumer read from?

Full set: 150 questions
Answer options
A: offset 2311 Correct answer
B: offset 0
C: offset 45
D: it will crash
Correct Answer:
A. offset 2311
Explanation

The consumer configuration auto.offset.reset=latest determines the starting point for a consumer when there is no previously committed offset for its consumer group. The value latest instructs the consumer to start reading from the end of the log. This means the consumer will skip all messages currently stored in the partition and will only begin processing new messages that are produced after the consumer has started. In this case, the last message in the partition is at offset 2311. The consumer will position itself at the end of the log to await the next message (which will be at offset 2312), effectively starting from the "latest" point.

Why Incorrect

B. offset 0: This is an arbitrary offset. The log for this partition starts at 45, so 0 is not a valid starting point.
C. offset 45: This would be the correct behavior if auto.offset.reset were set to earliest, which starts reading from the beginning of the available log.
D. it will crash: This is a standard and valid consumer configuration. The consumer is designed to handle this scenario and will not crash.

References

1. Confluent Documentation: In the "Consumer Configurations" section for Apache Kafka, the auto.offset.reset property is defined. The latest value specifies to "automatically reset the offset to the latest offset". This implies starting at the end of the log, processing only new messages.

Source: Confluent Documentation, Apache Kafka > Configuration > Consumer Configs, auto.offset.reset.

2. Apache Kafka Documentation: The official Kafka documentation provides the same definition, confirming this behavior is core to the Kafka consumer client.

Source: Apache Kafka Documentation, Section 3.4 "Consumer Configs", auto.offset.reset.

3. Academic/Authoritative Text: In "Kafka: The Definitive Guide," the authors explain the behavior clearly: "If auto.offset.reset is set to latest, consumers will start reading messages from the end of the partition." This means they will only see messages that are written after they start consuming.

Source: Narkhede, N., Shapira, G., & Palino, T. (2017). Kafka: The Definitive Guide. O'Reilly Media. Chapter 4, "Kafka Consumers: Reading Data from Kafka," subsection "Offsets and Consumer Position."

Scroll to Top