A developer is implementing a backend processing system using an Amazon SQS queue and an AWS Lambda function. The Lambda function processes messages in batches and has its timeout configured to 30 seconds. During peak hours, the developer notices that some messages are being processed multiple times by the Lambda function, despite the function successfully completing without errors. The developer also wants to ensure that messages that fail to process after 3 attempts are moved to a dead-letter queue (DLQ). Which two configurations must the developer implement to resolve the duplicate processing issue and properly configure the DLQ? (Choose two.)
- Increase the visibility timeout of the SQS queue to at least 180 seconds.Cevap
- Define a redrive policy on the source SQS queue that references the DLQ ARN and sets the maxReceiveCount to 3.Cevap
- CDefine a redrive policy on the DLQ that references the source SQS queue ARN and sets the maxReceiveCount to 3.
- DIncrease the SQS queue's visibility timeout to 35 seconds and increase the Lambda function's timeout to 45 seconds.
- EConfigure the SQS queue with a Delivery Delay of 180 seconds to allow Lambda sufficient execution buffer time.
Cevap
Increase the visibility timeout of the SQS queue to at least 180 seconds, and define a redrive policy on the source SQS queue that references the DLQ ARN and sets the maxReceiveCount to 3.
To prevent SQS from returning messages to the queue while a Lambda function is still processing them, the source queue's visibility timeout should be set to at least 6 times the timeout of the Lambda function. Since the Lambda function has a timeout of 30 seconds, the SQS visibility timeout must be configured to at least 180 seconds (). Additionally, to configure a dead-letter queue (DLQ) for failed messages, a redrive policy must be defined on the source SQS queue (not the DLQ itself) specifying the target DLQ ARN and a maxReceiveCount of 3.
Adım Adım Çözüm
Anahtar Kavram
SQS Visibility Timeout and DLQ Redrive Policy Configuration with Lambda Consumers