Skip to content
Middle+233 views

Why was a manual commit offset used instead of auto-commit?

Practice

AI answer

With manual offset commits, the consumer confirms its position in Kafka only after the message has been successfully processed and, if necessary, the result has been reliably written. This reduces the risk of losing a message: if a failure occurs before confirmation, it will be delivered again.

Auto-commit is simpler, but the offset may be confirmed before processing finishes—in that case, a failure will cause the message to be skipped. Manual commits are especially important for processing with side effects or long-running operations. In Go, it is important not to commit the offset before a successful result and to account for possible redelivery: it is best to make the handler idempotent. This typically provides “at least once” semantics, rather than guaranteeing exactly-once processing for arbitrary external systems.