liveBook · Manning

Offset

As explained in Kafka for Architects

A Kafka offset is a monotonically increasing integer that identifies a record's position within a partition or ordered record stream.

A Kafka offset is an integer that identifies a record’s position within a partition. Records are appended to that partition’s ordered log, starting at offset 0 and receiving increasing offsets. The combination of topic, partition, and offset uniquely identifies a record; an offset alone does not. Kafka preserves order within a partition, not across a topic’s partitions. section 2.2.1 section 2.4.3

Offsets also let consumers record where to resume. After polling and processing a batch, a consumer can commit its position—the offset of the next record to read. Kafka stores committed positions per consumer group in the internal __consumer_offsets topic. A commit records a place in the stream; it does not prove that processing succeeded. section 4.2 section 4.2.4

A restart after a premature commit

Suppose a consumer commits its position before finishing a database update for a record. If it fails, it resumes after that position and can skip the unfinished work. Automatic commits are convenient but can create this risk; for critical processing, commit manually after the work completes. If processing fails before a commit, the record can be read again. section 4.3.6 section 4.2.4

The position can also be used deliberately:

  • Start a consumer at a specified offset, or find an offset by timestamp, to read a chosen range—for example, to populate a microservice’s local store. Explicit positioning is programmed rather than set through consumer configuration. section 4.2.11
  • Compare a group’s committed offset with the latest produced offset to estimate consumer lag. Missing offsets, notably after compaction, make this calculation approximate. With workers completing out of order, advance the commit only through the highest contiguous offset whose work has finished. section 4.3.1
  • Diagnose a repeatedly failing invalid record by locating its offset. A command-line offset reset can move a stuck consumer past it, while a dead-letter topic provides a route for review. section 6.5.1

Offsets keep increasing when retention removes records; deleted positions are not reused. The word also has a related meaning in Kafka Connect: a source connector can store a source-system position, such as a database updated_time value, in connect-offsets. That value tracks what to load next, rather than identifying a Kafka record’s partition position. section 2.4.3 section 7.3.5

How Kafka for Architects covers it

How deep it goes
Defines partition positions and elaborates commit timing, explicit positioning, lag, and failure handling without descending into broker internals.
Examples
Uses local-store population, out-of-order worker completion, poison records, and database update timestamps to show offset decisions.
What it assumes
Defines offsets from partitioned topics while assuming familiarity with producers, consumers, and application processing.
What you can do after
Operate/configure consumer positioning and commits; diagnose lag or a repeatedly failing record using offsets.
How it connects
Connects partitions and consumer groups to retention, consumer lag, log compaction, and source connectors.

Also explained in

Compare how 4 books explain offset →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Kafka for Architects. The section links point to the parts of the book it draws on.