Interview kitsBlog

Your dream job? Lets Git IT.
Interactive technical interview preparation platform designed for modern developers.

XGitHub

Platform

  • Categories

Resources

  • Blog
  • About the app
  • FAQ
  • Feedback

Legal

  • Privacy Policy
  • Terms of Service

© 2026 LetsGit.IT. All rights reserved.

LetsGit.IT/Categories/Cloud
Cloudhard

At-least-once vs exactly-once delivery — why do we talk about idempotency?

Tags
#messaging#idempotency#retries
Back to categoryPractice quiz

Answer

With at-least-once delivery, a message can be delivered more than once (retries), so consumers must be idempotent (processing duplicates safely). Exactly-once is hard/expensive in practice, so idempotency is a common solution.

Advanced answer

Deep dive

Delivery semantics describe what happens under failures and retries:

  • **At-most-once**: no duplicates, but messages can be lost.
  • **At-least-once**: no loss (ideally), but duplicates can happen.
  • **Exactly-once**: no loss and no duplicates — very hard end-to-end once you include external side effects.

Because retries and timeouts are inevitable, many real systems choose at-least-once and rely on **idempotent consumers**.

How to make consumers idempotent

  • Deduplicate by message id (store processed ids for a retention window).
  • Use idempotency keys for commands (e.g., “charge card” with a unique key).
  • Use DB constraints/upserts to make repeated processing a no-op.
  • Use the outbox pattern to coordinate DB writes and message publishing.

Common pitfalls

  • “Exactly-once” in one component doesn’t guarantee end-to-end exactly-once.
  • Side effects (emails, payments) must be guarded with idempotency keys.
  • Dedup stores can become hot spots without good partitioning/

Related questions

DevOps
Infrastructure as Code: why does idempotency matter and how do you validate changes safely?
#iac#idempotency#terraform
MongoDB
MongoDB transaction write conflicts: why do they happen and how should you handle them?
#mongo#transactions#concurrency
Microservices
At-least-once delivery: how do you avoid duplicate side effects in a consumer?
#idempotency
TTL
.
#deduplication
#messaging
Microservices
What is a retry storm and how do you prevent it?
#retries#backoff#jitter
Databases
How can you make a write idempotent at the database level?
#idempotency#unique-constraint#upsert
Microservices
What is a schema registry and why is it useful for events?
#schema-registry#events#compatibility