Tutorials System Design Mastery

Dead Letter Queues: Handling poison messages gracefully

On this page

Resilient Messaging: The DLQ

What happens when a message is corrupted or causes your code to crash? Without a Dead Letter Queue (DLQ), that message will keep being retried forever, blocking the whole system. This is known as a **Poison Message**.

1. The Retry Policy

A resilient system should:

  1. Try to process the message.
  2. If it fails, wait 30 seconds and try again (Exponential Backoff).
  3. After 10 failed attempts, move it to the **DLQ**.

2. Managing the DLQ

The DLQ is like a "Hospital" for messages. They sit there safely without blocking the rest of the queue. Developers can then inspect the messages, fix the bug, and "Re-drive" (resend) them back into the main queue.

4. Interview Mastery

Q: "What is Idempotency and why is it mandatory for messaging?"

Architect Answer: "In a distributed system, a message might occasionally be delivered **Twice** (e.g., if the consumer crashes right after processing but before sending the 'Success' signal). An **Idempotent** operation is one that can be run 100 times with the same effect as running it once. If you are processing a payment, your code must check `HasThisOrderBeenPaidAlready?` before charging the credit card. Messaging is never 'Exactly Once'—it's always 'At Least Once,' so you must code for it."

Questions on this lesson 0

Sign in to ask a question or upvote helpful answers.

No questions yet — be the first to ask!

System Design Mastery
Course syllabus
1. Distributed Systems Fundamentals
2. Database Scalability
3. Caching & CDN Strategies
4. Event-Driven Architecture
5. High Availability & Load Balancing
6. Microservices & API Gateway
7. Monitoring & Disaster Recovery
8. FAANG System Design Interview
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details