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.