A developer is building a serverless application where an AWS Lambda function processes messages from an Amazon SQS queue. The function is configured to connect to an Amazon RDS MySQL database located in a private VPC subnet, and it also needs to make HTTPS requests to an external payment gateway API. The Lambda function's timeout is set to 15 seconds, and the SQS queue's visibility timeout is set to 10 seconds. During testing, the developer observes that messages are frequently being processed multiple times by the function, and all outbound requests to the payment gateway API fail due to network timeouts. Which configuration changes should the developer implement to resolve these issues?
- AIncrease the Amazon SQS queue visibility timeout to at least 90 seconds, and deploy the Lambda function in a public subnet with a route to an Internet Gateway.
- BDecrease the Lambda function timeout to 5 seconds to match the SQS visibility timeout, and deploy the Lambda function in private subnets with a route to a NAT Gateway.
- Increase the Amazon SQS queue visibility timeout to at least 90 seconds, and deploy the Lambda function in private subnets with a route to a NAT Gateway in a public subnet.Cevap
- DIncrease the Amazon SQS queue visibility timeout to at least 90 seconds, and add a policy to the Lambda function's IAM trust policy to allow outbound traffic to the payment gateway.
Cevap
Increase the Amazon SQS queue visibility timeout to at least 90 seconds, and deploy the Lambda function in private subnets with a route to a NAT Gateway in a public subnet.
The correct option successfully addresses the two core configuration issues. To prevent duplicate message processing, the SQS visibility timeout must be set to at least 6 times the function timeout ( seconds). To grant the Lambda function internet access while keeping database connectivity, it must be deployed in private subnets with a route pointing to a NAT Gateway in a public subnet.
Adım Adım Çözüm
Anahtar Kavram
Configuring SQS visibility timeout relative to Lambda timeout and routing outbound Lambda VPC network traffic.