Skip to main content

Question 27 of 50

What is Offset?

Mid-levelSenior

Question

"What is Offset in Kafka?"

What the interviewer wants to assess

Fundamental knowledge, usually used to open the discussion about commit and delivery guarantees. The detail that separates a correct answer from an incomplete one is understanding that offset is local to the partition.

Resposta rápida

Offset is an increasing integer, unique per partition, that identifies a record's position in the log. For a consumer, it represents "how far I've already read" within that specific partition.

Resposta nível Sênior

Offset isn't a global property of the topic — it's local to each partition. The same offset numbering exists independently in each partition of a topic: offset 100 on partition 0 and offset 100 on partition 1 are completely different records, with no relationship between them. There's also an important distinction between the consumer's in-memory read position (where the client has already delivered messages to the application) and the committed offset (what's persisted in Kafka as "processed"). Only the commit makes that progress official and lets it survive a consumer restart.

In-depth explanation

See "Offset" in Chapter 3 and the full deep dive in Chapter 7.

Exemplo financeiro

On the pix.recebido topic, the saldo-service keeps a committed offset per partition — if it restarts, it resumes from exactly the last committed offset, without rereading events already confirmed as processed (unless the commit hadn't happened yet before the restart).

"Offset is a global identifier for the message in the topic"

Offset is local to the partition, not the topic. Two messages from different partitions can have exactly the same offset number with no relationship between them — confusing this with a global message ID is a common mistake.

Pode vir a seguir

Likely follow-ups: "what is Commit?" and "what's the difference between Auto Commit and Manual Commit?".