At-Least-Once vs At-Most-Once vs Exactly-Once: Where to Use Each?

At-least-once delivery means every message arrives one or more times, so duplicates are possible. At-most-once means every message arrives zero or one time, so drops are possible. Exactly-once means each message takes effect one time, and it is built from at-least-once delivery plus deduplication or transactions. Kafka and Amazon SQS standard queues deliver at least once by default. The choice is made per flow, not per platform: a payment charge and a typing indicator in the same product need different guarantees.

At-least-once delivery

The broker, the service that stores and forwards messages, keeps a message until the consumer acknowledges it. The consumer processes the message first and acknowledges second. If the consumer crashes between those two steps, the broker redelivers, and the message is processed twice.

The consumer must therefore be idempotent, which means that processing the same message twice has the same effect as processing it once. The usual tools are an idempotency key, a unique id carried by each message, and a dedupe store that remembers processed keys for a bounded window, for example 24 hours. A database unique constraint on the key turns a duplicate insert into a rejected no-op.

Use at-least-once for inventory reservations recorded as ledger rows, analytics counters with commutative updates, and feed fan-out merged by event id. It is the default for any flow where losing a message is worse than seeing it twice.

At-most-once delivery

The consumer acknowledges the message before or as it starts processing. If the consumer crashes during processing, the message is gone. There is no retry, no dedupe store, and no coordination, so this is the lowest-latency and lowest-cost option.

Use at-most-once for signals where a miss is invisible or is corrected by the next refresh. Push notifications that a later app open will replace, typing indicators in chat, presence beacons, and sampled real-time metrics all fit. A financial event never fits.

Exactly-once delivery

No network can deliver a message exactly once, because a lost acknowledgment always forces a choice between a retry and a possible drop. What systems provide is an exactly-once effect: the message may arrive twice, but its result is applied once. Two patterns achieve this.

Transactional outbox and inbox. The producer writes its state change and the outgoing event in one local database transaction, so the event is never lost and never sent without the change. The consumer writes its business result and a processed marker in one transaction, so a redelivered event finds the marker and does nothing.

Checkpointed stream processing. A stream processor such as Apache Flink saves its state and its input offsets together in a checkpoint. After a crash it restores the checkpoint and replays input from that offset, and it writes to sinks with transactions or idempotent upserts. Kafka offers the same inside its own ecosystem with idempotent producers and transactions. SQS FIFO queues deduplicate by message id within a 5-minute window.

Use exactly-once for money movement, ledger updates, and entitlement or quota changes. It is worth the extra latency and infrastructure only when a duplicate costs more than the coordination.

A retail flow, step by step

Consider an order pipeline with five steps, each labeled with the guarantee it needs.

Payment charge: at least once with an idempotency key. The key is derived from the order id and the attempt number. The payment gateway stores it and returns the first result on a repeat, so the card is charged once.

Inventory reservation: at least once. Reservations are rows keyed by order id and SKU with a unique constraint. A duplicate reservation is rejected by the database.

Order confirmation email: at most once. A dropped email is recovered from the orders page or by a daily reconciliation job that resends failures.

Ledger posting: exactly once. The outbox pattern moves the event from the order service, and the inbox pattern on the ledger service applies it once.

Viewing or click analytics: at least once into the log, exactly once into the warehouse. Clients publish with retries, and a checkpointed aggregation job removes duplicates before the totals are written.

Comparison table

AspectAt least onceAt most onceExactly once
Delivery promiseOne or more deliveriesZero or one deliverySingle effect in the sink
Failure behaviorDuplicates possibleDrops possibleNo drops, no duplicate effects
LatencyMedium, retries and acksLowHigher, checkpoints or transactions
Ops complexityLow to mediumLowHigh
Consumer requirementIdempotent handler, dedupe storeTolerate lossTransactional or idempotent sink writes
Best fitReservations, fan-out, countersPush alerts, typing indicators, sampled metricsPayments, ledgers, quota updates
Typical toolsKafka default, SQS standard, RabbitMQ manual acksNon-durable queues, fire-and-forget signalsFlink checkpoints, Kafka transactions, outbox and inbox

Delivery semantics vs processing semantics

Delivery semantics describe how many times the broker hands a message to a consumer. Processing semantics describe how many times the message's effect is applied. A system can have at-least-once delivery and exactly-once processing at the same time, and that combination is what most production systems mean when they claim exactly once. Plan for reprocessing from the start: a replay of last week's events must produce the same totals as the live run.

Key Takeaways

  • At least once is the default. It needs idempotent consumers, which means an idempotency key and a dedupe store or a unique constraint.
  • At most once is for signals nobody will miss. No retries, no dedupe, lowest latency.
  • Exactly once is an effect, not a delivery. Build it from retries plus the outbox and inbox pattern or checkpointed stream processing.
  • Label each flow, not the platform. In an interview, name five steps of the pipeline and state the failure each one can accept.

Messaging and delivery guarantees are covered with diagrams in Grokking System Design Fundamentals.

Grokking the System Design Interview applies these choices to full designs such as a payment system and a notification service.

The outbox, idempotent consumer, and checkpoint patterns are explained in System Design Patterns.

TAGS
System Design Interview
System Design Fundamentals
CONTRIBUTOR
Arslan Ahmad
Arslan Ahmad
ex-FAANG engineering manager and author or Grokking series.

GET YOUR FREE

Coding Questions Catalog

Design Gurus Newsletter - Latest from our Blog
Boost your coding skills with our essential coding questions catalog.
Take a step towards a better tech career now!
Explore Answers
What is Apple's interview process?
Which position is highest paid in Apple?
What Is MCP (Model Context Protocol)?
MCP is an open standard that lets an AI application discover and call tools, read data, and load prompts from independent servers over one JSON-RPC format. What it replaces, its three roles, and why the design matters.
What Is the Elastic Interview Process Like? (Round by Round)
The Elastic interview rounds for engineers: recruiter screen, hiring manager call, technical interviews, and the Source Code values round.
What Is the Difference Between Weak and Strong Scaling?
Strong scaling keeps the problem fixed and adds processors to finish sooner. Weak scaling grows the problem with the processors to keep the time constant. Here are the definitions, the formulas, and a worked example of each.
Who Is the Highest Paid Employee at Tesla?
Elon Musk, and almost none of it is salary. His Tesla pay is stock that only vests when the company hits set targets, and his base salary is zero.
Related Courses
New
Grokking the AI System Design Interview course cover
Grokking the AI System Design Interview
Learn to design AI systems the way interviewers expect: classic ML products, LLM and RAG architectures, and agentic systems, all through the lens of the system design interview.
4.6
(3,192 learners)
Discounted price for Your Region

$99

Grokking the Coding Interview: Patterns for Coding Questions course cover
Grokking the Coding Interview: Patterns for Coding Questions
The 24 essential patterns behind every coding interview question. Available in Java, Python, JavaScript, C++, C#, and Go. The most comprehensive coding interview course with 543 lessons. A smarter alternative to grinding LeetCode.
4.6
Discounted price for Your Region

$197

Grokking Modern AI Fundamentals course cover
Grokking Modern AI Fundamentals
Master the fundamentals of AI today to lead the tech revolution of tomorrow.
4.1
Discounted price for Your Region

$72

Design Gurus logo
One-Stop Portal For Tech Interviews.
About Us
Our Team
Careers
Partners
Contact Us
Become Affiliate
Copyright © 2026 Design Gurus, LLC. All rights reserved.