Explain the differences between Kafka's at-least-once, at-most-once, and exactly-once processing guarantees.

Instruction: Describe the three types of processing guarantees provided by Kafka and the scenarios in which each would be most appropriate.

Context: This question assesses the candidate's knowledge of Kafka's delivery semantics and their ability to choose the appropriate guarantee based on specific use cases.

Updated

Official answer

The guarantee must name its boundary: broker append, Kafka output plus consumer progress, or an external business effect.

At-most-once processing permits skipped work but avoids replay caused by the chosen acknowledgement order. For example, committing the next offset before processing means a crash afterward can leave that record unprocessed. Use this only when such loss is acceptable under the application contract; producer/application duplicates may still require separate handling.

At-least-once processing completes work before committing progress. A crash after the effect but before the commit can repeat that effect on restart. Make effects idempotent or deduplicate them when duplicates are unacceptable. Retention, durable acknowledgements and recovery still matter; the label is not protection against every failure.

Kafka exactly-once read-process-write processing combines transactional output with input group offsets and uses read_committed visibility. Aborted attempts can execute application code without becoming committed Kafka output. It therefore does not mean the code literally ran once, nor that an arbitrary external database or email participated atomically.

For an external projection, a unique event ID and the projection update can be committed together in a database transaction. A repeated ID then produces no repeated business change. The exact protocol and its crash boundaries must be tested.

Choose the weakest guarantee that meets the business requirement, accounting for reconciliation, latency and operating cost. Do not infer the correct mechanism from an industry label alone.

Kafka delivery semantics, transactional producer

Related Questions