What is a Dead Letter Queue (DLQ) in serverless?
Answer
A Dead Letter Queue (DLQ) is a queue where unprocessable messages (failed function invocations) are sent for later inspection and reprocessing. For asynchronous Lambda invocations (S3, SNS, EventBridge triggers) — Lambda automatically retries failed invocations twice, then sends the failed event to the configured DLQ (SQS or SNS). For SQS-triggered Lambda — after the SQS message's MaxReceiveCount is exceeded (typically 3–5 retries), SQS itself moves the message to its DLQ. DLQs serve as a poison pill detector: messages that fail repeatedly (due to bad data, unhandled exceptions, or external service outages) are quarantined for investigation rather than being retried forever or silently dropped. Best practices: (1) Configure alarms on DLQ message count to alert on failures; (2) Build reprocessing logic to replay DLQ messages after fixing the root cause; (3) Include contextual metadata (function name, trigger event, error) in the DLQ message for debugging.
Previous
How do you handle database connections in serverless functions?
Next
How do you implement microservices with serverless?
More Serverless Architecture Questions
View all →- Intermediate How do you reduce cold start latency in serverless functions?
- Intermediate What is AWS Step Functions and when would you use it?
- Intermediate How do you handle state in serverless applications?
- Intermediate What is the Serverless Framework and how does it work?
- Intermediate How do you implement authentication in a serverless API?