Interview's MateSystem Design
Interview's Mate

System Design

Architecture & trade-offs

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
All topics/Message Queues & Event Streaming
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
Practice in AI HLD
Subtopics in Message Queues & Event Streaming (2)
OverviewKafka PartitionsAt-Least-Once & DLQ

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
Previous subtopic
Kafka Partitions, Consumer Groups & Ordering
Back to overview
Full Message Queues & Event Streaming Lesson