The Importance of Dead Letter Queues in AWS Lambda
Instruction: Explain what a Dead Letter Queue (DLQ) is and how it can be used with AWS Lambda.
Updated
Official answer
A dead-letter destination retains an event that could not be processed within the configured attempts or age, so an operator can investigate and deliberately replay it.
For Lambda asynchronous invocation, a function DLQ can be a supported SQS queue or SNS topic. An SNS topic is a publisher to subscribers, not a durable work queue by itself. Lambda sends the original event with diagnostic attributes after its asynchronous processing policy is exhausted. An on-failure destination is an alternative that carries a richer invocation record. Check the destination type's permissions, encryption and size limits.
For an SQS event source mapping, configure redrive and the DLQ on the source SQS queue. The function's asynchronous DLQ setting does not handle those polled SQS records. Visibility timeout, retention and maximum receive count must allow the intended processing and recovery window.
A DLQ is not a no-loss guarantee. Missing permissions or an oversized message can prevent delivery. Monitor DeadLetterErrors or DestinationDeliveryFailures as applicable, plus queue age and alarms. Protect retained payloads as sensitive data when necessary.
Define an owner, investigation procedure and controlled replay rate. Fix the cause first, preserve a stable business operation ID, and check for prior side effects before replay; a failed attempt may already have changed an external system.
Asynchronous retention and SQS distinction, asynchronous retries