Lesson 1 of 9 · 24m
Delivery Guarantees in Real Queues
Learn why at-most-once, at-least-once, and exactly-once describe delivery attempts rather than business effects — and how to choose the right guarantee.
The first queue outage that teaches you humility usually starts with someone saying, "But the queue guarantees exactly-once delivery." No, it doesn't. At best it guarantees exactly-once delivery attempts under narrow conditions. Your worker can still crash after charging the card but before acknowledging the message. Day-one rule: design for repeated delivery and incomplete side effects.
The three guarantees are operational trade-offs
At-most-once means the system acknowledges before doing the work. A crash loses the job, but you never see it twice. It is appropriate for metrics sampling or cache warming where loss is cheap.
At-least-once means the system redelivers when acknowledgement is uncertain. A crash duplicates work, but jobs are not silently lost. Most production systems choose this and make workers idempotent.
Exactly-once is usually a transaction spanning the queue plus a state store, or a marketing simplification. It can be real inside one system — Kafka transactions, for example — but it does not magically make an external payment API transactional.
Read the actual semantics
Do not infer behavior from the word "queue" in the product name. Read the delivery documentation:
Amazon SQS standard at-least-once, best-effort ordering, possible duplicates
Amazon SQS FIFO exactly-once processing window, ordering per group, throughput limits
RabbitMQ acknowledgement-based redelivery, ordering mostly per queue
Kafka consumer offset control, replay by design, ordering per partition
Redis streams explicit pending entries and consumer groups
Postgres skip locked database-backed lease semantics, transactional dequeueEach system pushes failure somewhere different. Managed queues hide server operations but expose visibility timeouts. Brokers with manual acknowledgements expose exactly where ambiguity lives.
The dangerous gap is after the side effect
A worker normally follows this shape:
msg = receive()
perform_external_side_effect(msg)
ack(msg)If the process dies between steps two and three, the message returns and the effect happens again. Moving ack earlier only trades duplicates for loss. The fix is not clever ordering; it is making step two safe to repeat.
Choose by failure cost
Ask what happens if the job is lost, duplicated, delayed, or reordered. A password-reset email tolerates duplicates poorly but loss catastrophically. A thumbnail render tolerates both loss through regeneration and duplication through overwrite. A ledger posting tolerates neither loss nor duplication, so it needs a transactional outbox and idempotent consumer.
Field notes
- "Deduplication" in queues is usually time-windowed. It reduces duplicates; it does not prove exactly-once processing.
- If a queue offers both standard and FIFO modes, the FIFO choice costs throughput and changes key design. Do not enable it as a superstition.
- Bursts matter. A queue can preserve ordering in a single partition while the fleet as a whole processes messages out of order.
- Write the delivery assumption in the worker README. Future maintainers will otherwise infer the wrong one from the happy path.
Was this lesson helpful?