Question 28 of 50
What is Commit?
Question
"What is Commit in the context of a Kafka consumer?"
What the interviewer wants to assess
Whether you understand commit as the act that officializes read progress — and its implications when the commit's timing is wrong relative to actual processing.
Resposta rápida
Commit is the operation that records, for a Consumer Group, up to which offset of a partition has already been processed. It can be automatic (the client commits periodically in the background) or manual (the application decides exactly when to commit).
Resposta nível Sênior
Commit is what separates "the client already delivered this message to the application" from "Kafka considers this message processed for this Consumer Group." Between the moment a message is delivered and the moment its offset is committed, there's a window where, if the consumer crashes, that message can either be reprocessed (if not yet committed) or lost (if committed before processing finished). It's that timing — not the existence of the commit itself — that determines whether the consumer tends to lose or duplicate messages under failure.
In-depth explanation
See "Auto Commit" and "Manual Commit" in Chapter 7.
Exemplo financeiro
The cobranca-service only calls acknowledgment.acknowledge() (commits the offset) after confirming the
collection notification was sent and recorded in the database — guaranteeing that a failure mid-process
results in reprocessing, never a silent loss of the invoice.
"Commit and reading are the same thing"
No — a consumer can read (and even process) a message without ever committing its offset, if it crashes first. In that case, the consumer's next startup will reread the same message, because the commit never happened.
Pode vir a seguir
Likely follow-ups: "what's the difference between Auto Commit and Manual Commit?" and "what is Retention Period?".
Related chapters