Delivery semantics

At-least-once + idempotent sink as the workhorse; exactly-once via transactions/2PC and what it costs. Explain where duplicates come from (producer retries, rebalances) and where you kill them.

About 24 min read3-question knowledge check

The mental model

Delivery semantics answer one question: when things fail and retry, how many times does each event take effect downstream? At-most-once (may lose), at-least-once (may duplicate), exactly-once (neither — at a price).

The analogy: sending money by mail. At-most-once is dropping cash in a postbox — cheap, and if the letter is lost, the money is gone. At-least-once is certified mail with an aggressive resend policy — nothing is ever lost, but if the confirmation gets lost on its way back to you, you resend and your friend may receive the money twice. Exactly-once is a bank transfer — an escrow protocol with both sides confirming, noticeably slower and more machinery, and still built out of retries plus deduplication under the hood.

Why this topic exists at all: networks lose acknowledgments, not just messages. A producer sends a record, the broker writes it, the ack is lost, the producer retries — the broker now has it twice. A consumer processes a record, crashes before committing its offset, restarts — it processes the record again. Every duplicate in a data platform comes from a retry somewhere whose success was invisible to the retrier. You cannot configure retries away (removing them gives you at-most-once, i.e., loss), so the game is: generate duplicates freely, then make them harmless.

The production workhorse, worth stating as a slogan: at-least-once delivery + idempotent sink = effectively exactly-once results. True exactly-once delivery across arbitrary systems does not exist; exactly-once processing within a closed system (Kafka transactions, Flink checkpoints + transactional sinks) does, and costs latency.

The full lesson continues with 15 more sections
  • Deep dive
  • Internal architecture
  • Real-world use cases
  • Best practices
  • Common mistakes
  • Performance
  • Security
  • Production troubleshooting
  • Advantages & disadvantages
  • Alternatives
  • Interview expectations
  • Interview questions
  • Facts to remember
  • Cheat sheet
  • Quick revision