What is an offset, and how does a consumer use it?
Sketch your own answer first, then compare it with the one below.
A strong answer
An offset is the position of a message inside one partition, counted from the start. It never changes for that message.
A consumer remembers the offset of the next message it should read. It saves that value from time to time, which is called committing. After a restart, it begins from the committed offset.
Work done after the last commit is repeated, so consumers should tolerate repeats. An offset only means something inside its own partition.
Sources
- Jay Kreps, Neha Narkhede, Jun Rao (2011). Kafka: a distributed messaging system for log processing.
- Martin Kleppmann (2017). Designing Data-Intensive Applications.