A developer is troubleshooting a serverless application where an AWS Lambda function is triggered by an Amazon SQS queue to process incoming batch jobs. The Lambda function has a configured timeout of minutes. The Amazon SQS queue has a visibility timeout of seconds. During testing, the developer observes that messages are frequently being processed multiple times by parallel Lambda invocations before being successfully deleted.
Which configuration change will resolve this issue?
- Increase the visibility timeout of the Amazon SQS queue to at least minutes.Cevap
- BIncrease the timeout of the AWS Lambda function to minutes.
- CDeploy the AWS Lambda function inside a private VPC subnet with no NAT Gateway.
- DSwitch the SQS integration to use API Gateway Lambda Proxy integration to manage message routing.
Cevap
Increase the visibility timeout of the Amazon SQS queue to at least minutes.
Increasing the visibility timeout of the Amazon SQS queue to at least minutes is the correct action. AWS recommends configuring the visibility timeout of the source SQS queue to at least times the timeout of the Lambda function. Since the function has a timeout of minutes, the queue's visibility timeout must be set to at least minutes to ensure messages do not become visible to other concurrent invocations while the current execution is still running.
Adım Adım Çözüm
Anahtar Kavram
Amazon SQS Visibility Timeout alignment with AWS Lambda Timeout