DISTRIBUTED SYSTEMS & ARCHITECTURE · SUBTOPIC
Delivery Guarantees & Dead-Letter Queues (DLQ)
Build idempotent consumers and handle poison-pill messages safely.
IntermediatePart of Message Queues & Event Streaming
Subtopics in Message Queues & Event Streaming (2)
In plain words
Because networks can drop acknowledgments, queues usually promise "at-least-once" delivery - meaning you might get a letter twice, so your worker must safely ignore duplicates. Poison messages that fail 5 times move to a side bin (DLQ) instead of blocking everyone behind them.
Think of it like…
Putting unreadable mail in an "Exception Bin" (DLQ) so the rest of the conveyor belt keeps moving.
Loading interactive diagram
Loading interactive exercise
Theory & how it works
Why "At-Least-Once + Idempotent Consumer" is the real-world gold standard
True distributed "exactly-once" across arbitrary databases and external APIs (like Stripe or SendGrid) is impossible or very slow. In practice, systems use at-least-once delivery and store processed event_ids in a unique index or Redis so duplicate deliveries are harmless no-ops.
Key points & practical guide
Summary checklist
- Design every consumer to be idempotent
- Use exponential backoff + DLQ for poison-pill messages
- Monitor DLQ depth and consumer lag as key alerts
When to use it
- Every async worker, webhook processor, and event consumer
Watch out for
- Infinite immediate retries on a malformed JSON payload - burns 100% CPU and blocks the partition
Quick check
Loading quiz