Delivery Semantics (At-Most-Once, At-Least-Once, Exactly-Once Semantics)
Reason about at-most/at-least/exactly-once and what EOS actually guarantees end to end.
In plain words
Broker, DB, or external service. Next, SLO and business cost. Finally, after process, before commit, and during retry.
Think of it like…
Delivery semantics describe how often a courier may knock: once at risk of loss, repeated until heard, or a coordinated handoff only when the receiving ledger and courier share a transaction.
Where you’ve seen it
Kafka Streams consumes, updates state, and produces atomically with processing.guarantee=exactly_once_v2; a Postgres sink still uses a unique event_id MERGE because no Kafka transaction spans Postgres.
Words you’ll hear
- At-Least-Once
- A policy that never knowingly retries delivery, allowing an acknowledged processing gap after failure.
- EOS
- A policy that retries until success, requiring consumers to handle repeated logical records.
- Idempotency
- Scoped atomic input-offset/output semantics, plus idempotency when any external side effect crosses transaction systems.
- Operational boundary
- A team calls Kafka transactions end-to-end EOS while the HTTP email provider receives two calls, or a commit-after-sink design duplicates records because the sink and input offset are in different failure domains. Choose semantics per boundary, make consumers idempotent, use a broker transaction for read-process-write within Kafka, and use transactional outbox or unique idempotency keys for external/database sinks.
Visual diagram
Theory & deep dive
At-Least-Once: the working mechanism
At-most-once accepts loss before retry, at-least-once retries and therefore permits duplicates, and exactly-once is a scoped transaction/offset guarantee-not a promise that external arbitrary side effects happen once.
Broker, DB, or external service. SLO and business cost, then transaction, outbox, or idempotency key; this exposes the state governed by Idempotency.
Kafka Streams consumes, updates state, and produces atomically with processing.guarantee=exactly_once_v2; a Postgres sink still uses a unique event_id MERGE because no Kafka transaction spans Postgres.
Delivery Semantics: failure mode and production response
A team calls Kafka transactions end-to-end EOS while the HTTP email provider receives two calls, or a commit-after-sink design duplicates records because the sink and input offset are in different failure domains.
Choose semantics per boundary, make consumers idempotent, use a broker transaction for read-process-write within Kafka, and use transactional outbox or unique idempotency keys for external/database sinks. Track Duplicate window as "crash point between sink success and offset commit", and make Idempotency retention visible to the dataset owner.
How it works, step by step
Step 1 of 41. Define atomic boundary
Broker, DB, or external service. At-most-once accepts loss before retry, at-least-once retries and therefore permits duplicates, and exactly-once is a scoped transaction/offset guarantee-not a promise that external arbitrary side effects happen once.
- Duplicate window
- crash point between sink success and offset commit
- EOS
- A policy that retries until success, requiring consumers to handle repeated logical records.
When to use it & trade-offs
What it is
At-most-once accepts loss before retry, at-least-once retries and therefore permits duplicates, and exactly-once is a scoped transaction/offset guarantee-not a promise that external arbitrary side effects happen once. Kafka Streams consumes, updates state, and produces atomically with processing.guarantee=exactly_once_v2; a Postgres sink still uses a unique event_id MERGE because no Kafka transaction spans Postgres.
Why it matters: A team calls Kafka transactions end-to-end EOS while the HTTP email provider receives two calls, or a commit-after-sink design duplicates records because the sink and input offset are in different failure domains. Choose semantics per boundary, make consumers idempotent, use a broker transaction for read-process-write within Kafka, and use transactional outbox or unique idempotency keys for external/database sinks.
When to reach for it
- Reason about at-most/at-least/exactly-once and what EOS actually guarantees end to end.
- Choose At-Least-Once because it provides this capability: A policy that never knowingly retries delivery, allowing an acknowledged processing gap after failure.
- Keep evidence for Duplicate window at "crash point between sink success and offset commit" so the last production stage-Test crash points - after process, before commit, and during retry-remains testable.
When to avoid or be careful
- A team calls Kafka transactions end-to-end EOS while the HTTP email provider receives two calls, or a commit-after-sink design duplicates records because the sink and input offset are in different failure domains.
- Do not conflate EOS with At-Least-Once. The second concept contributes different behavior: A policy that retries until success, requiring consumers to handle repeated logical records.
- Release only after this guardrail is in place: Choose semantics per boundary, make consumers idempotent, use a broker transaction for read-process-write within Kafka, and use transactional outbox or unique idempotency keys for external/database sinks.
At-Least-Once / EOS / Idempotency - roles, limits, and operating cost
Strengths: A policy that never knowingly retries delivery, allowing an acknowledged processing gap after failure. At-most-once accepts loss before retry, at-least-once retries and therefore permits duplicates, and exactly-once is a scoped transaction/offset guarantee-not a promise that external arbitrary side effects happen once.
Watch out: A team calls Kafka transactions end-to-end EOS while the HTTP email provider receives two calls, or a commit-after-sink design duplicates records because the sink and input offset are in different failure domains.
Strengths: A policy that retries until success, requiring consumers to handle repeated logical records. In this workflow it supports: Coordinate - transaction, outbox, or idempotency key.
Watch out: The operating cost is real: event key dedupe state must cover retry horizon.
Strengths: Scoped atomic input-offset/output semantics, plus idempotency when any external side effect crosses transaction systems. Its output can be checked with Atomic boundary.
Watch out: Operating guardrail: Choose semantics per boundary, make consumers idempotent, use a broker transaction for read-process-write within Kafka, and use transactional outbox or unique idempotency keys for external/database sinks.
Interview signals & numbers to know
When this topic comes up
- “Where is the failure boundary for At-Least-Once, and how would Duplicate window reveal it?”
- “Why is EOS distinct from this behavior: scoped atomic input-offset/output semantics, plus idempotency when any external side effect crosses transaction systems?”
- Production clue: A team calls Kafka transactions end-to-end EOS while the HTTP email provider receives two calls, or a commit-after-sink design duplicates records because the sink and input offset are in different failure domains.
- Design probe: Choose semantics per boundary, make consumers idempotent, use a broker transaction for read-process-write within Kafka, and use transactional outbox or unique idempotency keys for external/database sinks.
Benchmarks & rules of thumb
- Duplicate window
- crash point between sink success and offset commit
- Idempotency retention
- event key dedupe state must cover retry horizon
- Atomic boundary
- explicit systems that participate in the same transaction
Common mistakes & follow-ups
Common interview mistakes
- A team calls Kafka transactions end-to-end EOS while the HTTP email provider receives two calls, or a commit-after-sink design duplicates records because the sink and input offset are in different failure domains.
- Reporting success from a job exit code without checking Duplicate window and Idempotency retention.
- Treating this example as complete without replay, rollback, or access boundaries: Kafka Streams consumes, updates state, and produces atomically with
processing.guarantee=exactly_once_v2; a Postgres sink still uses a uniqueevent_idMERGE because no Kafka transaction spans Postgres.
Likely interviewer follow-ups
- How would you prove this contract instead of only checking that the command ran: A policy that never knowingly retries delivery, allowing an acknowledged processing gap after failure.
- What does the recovery plan do when this occurs? A team calls Kafka transactions end-to-end EOS while the HTTP email provider receives two calls, or a commit-after-sink design duplicates records because the sink and input offset are in different failure domains.
- When is At-Least-Once insufficient for Idempotency retention, and what does adding EOS cost in Duplicate window?
Knowledge check
Put it into practice
Practice related interview Q&A
Apply Delivery Semantics (At-Most-Once, At-Least-Once, Exactly-Once Semantics) with data engineer interview Q&A and hands-on practice.