- Newest
- Most votes
- Most comments
Your setup is correct for avoiding retries when using SQS and Lambda. The maxReceiveCount property set to 1 on the RedrivePolicy of the SQS queue ensures that the failed records are moved to the Dead Letter Queue (DLQ) immediately after the first failed attempt. This behavior is independent of whether AWS Lambda retries the batch before moving it to the DLQ.
Regarding your observation that records did not go immediately to the DLQ even if the function was throttled, this behavior may occur if the throttling occurred after the records had been dequeued from the SQS queue but before they could be processed by the Lambda function. In this case, Lambda will retry the function invocation for up to six hours with an exponential backoff. However, if the maximum number of retries (which is one, in your case) is reached, the failed records will be moved to the DLQ.
Note that setting the reserved concurrency for a Lambda function to 0 can be used for testing purposes to ensure that the function is throttled. However, in a production environment, this may not be the best way to ensure throttling, as it could result in a complete halt of your processing. Instead, you can consider setting an appropriate concurrency limit that matches the capacity of your downstream resources, such as your database or other AWS services.
Relevant content
- Accepted Answerasked 10 months ago
- asked 4 months ago
- asked 4 years ago
- AWS OFFICIALUpdated 22 days ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 6 months ago