A developer is implementing a game state update system where player level-up events are sent to an Amazon SQS queue. An AWS Lambda function is configured to consume messages from the queue and process the updates. The Lambda function has its timeout configured to 50 seconds. The SQS queue has a visibility timeout of 20 seconds. During testing, the developer notices that some level-up events are being processed multiple times by different Lambda invocations. Which configuration change will prevent the duplicate processing of these messages?
- Increase the visibility timeout of the Amazon SQS queue to at least 50 seconds.Cevap
- BIncrease the timeout of the AWS Lambda function to 90 seconds.
- CDecrease the visibility timeout of the Amazon SQS queue to 10 seconds.
- DChange the Lambda function's IAM execution role to have trust relationships with the SQS queue.
Cevap
Increase the visibility timeout of the Amazon SQS queue to at least 50 seconds.
The correct option is to increase the visibility timeout of the Amazon SQS queue to at least 50 seconds. SQS visibility timeout prevents other consumers from receiving and processing a message that is currently being processed. If the consumer (the Lambda function) takes up to 50 seconds to complete, the visibility timeout must be at least 50 seconds so that the message remains invisible until the Lambda function successfully deletes it.
Adım Adım Çözüm
Anahtar Kavram
Amazon SQS visibility timeout must be configured to be greater than or equal to the processing timeout of the consumer to prevent duplicate processing.
Tahmini Süre:1m 0s