At-most-once, at-least-once, and why exactly-once is hard everywhere
coreintermediateThis 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.
Think of it as
Imagine mailing a signed contract and needing confirmation it arrived. At-most-once is sending it once and never checking — if it's lost in the mail, you never know and never resend. At-least-once is resending it every time you don't get a confirmation — safe against loss, but if the confirmation itself was the thing that got lost (not the contract), the recipient now has two signed copies. Exactly-once would mean somehow guaranteeing one copy arrives no matter what — genuinely hard, because you can't tell "contract lost" apart from "confirmation lost" from where you're standing.
What we're doing: Show the exact ambiguity that makes true exactly-once delivery hard — a lost acknowledgment looks identical to a lost message.
- 4
- This is the case retrying correctly recovers from — the message never arrived.
- 15
- This is the ambiguity itself: two completely different real outcomes produce the exact same observation at the caller.
Why this works: This ambiguity is not a bug in any particular system — it is a fundamental property of any request/response over an unreliable network, which is why "exactly-once, guaranteed by the delivery mechanism alone" is not achievable in general, only approximated via idempotency on the receiving side.
Believing a specific technology choice (a particular broker, a particular protocol) solves exactly-once for you
Wrong
Better
What you see: A duplicate side effect (double charge, duplicate email, duplicate order) occurs in a system built on a messaging technology marketed as "exactly-once," and the team is caught off guard because they treated the marketing claim as covering their entire pipeline rather than the specific internal boundary it actually applies to.
Why: The fundamental ack-ambiguity problem applies at every network boundary a message crosses — a technology can only close that gap for hops it fully controls both ends of (like Kafka producing and consuming within itself); the moment a message reaches something the technology doesn't control (an external API, a different system), the ambiguity is back.
- 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
The three semantics, generalized across any distributed messaging system
Remember: 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.
See also: idempotent consumer design · idempotency implementation · delivery guarantees

