Interview's MateData Engineer
Interview's Mate

Data Engineer

SQL · Spark · Lakehouse · Streaming

Visualizer

DSA Visualizer
All 32 lessons
Custom Playground
Try your own examples

Learning

System Design
31 architecture topics
SQL Learning
160 foundations → production topics
AI Engineering
160 LLM → backend topics
Data Science
160 Python → MLOps topics
Data Engineer
160 SQL → streaming topics
Docker
160 Docker learning topics
Kubernetes
160 K8s fundamentals → cloud
Java LearnSoon
Coming soon
Python Learn
Interview Q&A & internals
JavaScript Learn
Closures, async & DOM Q&A
Tech Learn
Search, practise & track Q&A
AI DSA Practice
Solve coding problems
Theme
Home
Data Engineer topics
Lesson 126/ 160
07. Streaming & Real-Time Data Engineering

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.

AdvancedAt-Least-Once · EOS · Idempotency3 quiz questions
Practice Generative AI Q&A
In plain wordsDiagramTheoryStep by stepWhen to use itInterview cluesMistakes to avoidQuiz (3)Practice

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

Loading interactive 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.

Delivery Semantics in one concrete design

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.

Key takeaway: 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

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.

Key takeaway: 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.

How it works, step by step

Step 1 of 4
At-Least-Once

1. 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.

broker, DB, or external service
Key numbers at this step
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

At-Least-Once
Best for: A policy that never knowingly retries delivery, allowing an acknowledged processing gap after failure.

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.

EOS
Best for: A policy that retries until success, requiring consumers to handle repeated logical records.

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.

Idempotency
Best for: Scoped atomic input-offset/output semantics, plus idempotency when any external side effect crosses transaction systems.

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 unique event_id MERGE 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?
Interview tip: Lead with the data path and failure boundary: 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. Then make the answer operational: 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.

Knowledge check

Loading quiz

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.

Open Data Engineer Q&A →Machine Learning Q&A
Previous topic
Kafka Consumers, Consumer Groups, Rebalancing & Offset Management
Next topic
Schema Registry & Data Contracts (Avro, Protobuf, JSON Schema Compatibility)