Dead Letter Queues - Serverless Architectures with AWS Lambda

Dead Letter Queues

Even in the serverless world, exceptions can still occur. (For example, perhaps you’ve uploaded new function code that doesn’t allow the Lambda event to be parsed successfully, or there is an operational event within AWS that is preventing the function from being invoked.) For asynchronous event sources (the event InvocationType), AWS owns the client software that is responsible for invoking your function. AWS does not have the ability to synchronously notify you if the invocations are successful or not as invocations occur. If an exception occurs when trying to invoke your function in these models, the invocation will be attempted two more times (with back-off between the retries). After the third attempt, the event is either discarded or placed onto a dead letter queue, if you configured one for the function.

A dead letter queue is either an SNS topic or SQS queue that you have designated as the destination for all failed invocation events. If a failure event occurs, the use of a dead letter queue allows you to retain just the messages that failed to be processed during the event. Once your function is able to be invoked again, you can target those failed events in the dead letter queue for reprocessing. The mechanisms for reprocessing/retrying the function invocation attempts placed on to your dead letter queue is up to you. For more information about dead letter queues, see this tutorial. You should use dead letter queues if it’s important to your application that all invocations of your Lambda function complete eventually, even if execution is delayed.