1.At-most-once, at-least-once, and why exactly-once is hard everywhere
This is the general version of the delivery-guarantee trade-off that shows up in every distributed messaging system, not just Kafka: at-most-once may silently lose work, at-least-once may silently duplicate it, and exactly-once — never losing and never duplicating — is fundamentally hard to guarantee once a message crosses any network boundary, because the sender can never be certain the receiver's acknowledgment wasn't lost after the work actually succeeded.
Key features
- At-most-once: send/process without confirming — never duplicates, but a lost message is gone with no automatic recovery
- At-least-once: retry until confirmed — never silently loses work, but a lost confirmation causes a real duplicate delivery, not just a theoretical one
- The reason exactly-once is hard: the sender cannot distinguish "the message was lost" from "the message succeeded but the acknowledgment was lost" — both look identical (no ack received) from the sender's side
- True exactly-once delivery would require the sender and receiver to agree atomically on outcome across a network — which for two independent systems generally cannot be done without one of them accepting extra coordination cost (e.g. Kafka's transactions, scoped to Kafka-to-Kafka)
- The practical, achievable target for almost every real system is at-least-once delivery combined with idempotent processing — producing the effect of exactly-once without requiring the delivery layer itself to guarantee it
The three semantics, generalized across any distributed messaging system
- Message lost
- Request never reaches B (network drop)
- B never processes the payment
- A sees a timeout — no response
- Ack lost
- B receives it, processes it, sends 200 OK
- The response is lost on the way back
- A sees the exact same timeout
Signature
at-most-once: may lose · at-least-once: may duplicate · exactly-once: needs idempotency, not just delivery
At-most-once can silently lose work; at-least-once can silently duplicate it; true exactly-once is fundamentally hard because a sender can never tell "message lost" apart from "acknowledgment lost." The practical target is at-least-once delivery plus idempotent processing.