An e-commerce application has a backend worker service running on Amazon EC2 instances that processes order fulfillment messages from an Amazon SQS standard queue. Each order takes approximately 25 seconds to process and complete. However, during testing, the developer observes that multiple EC2 instances are processing the same order message simultaneously. Which action should the developer take to resolve this duplication issue?
- ADecrease the Visibility Timeout of the Amazon SQS queue to a value less than 25 seconds.
- BConfigure the worker application to initialize the AWS SDK client using hardcoded AWS access keys with higher privilege.
- Increase the Visibility Timeout of the Amazon SQS queue to a value greater than 25 seconds.Cevap
- DDecrease the execution timeout of the EC2 worker application components to less than 25 seconds.
Cevap
Increase the Visibility Timeout of the Amazon SQS queue to a value greater than 25 seconds.
Increasing the visibility timeout of the SQS queue beyond the processing time of 25 seconds prevents other worker instances from seeing and consuming the message while it is being actively processed. Once the worker finishes processing, it deletes the message, preventing duplicate processing altogether.
Adım Adım Çözüm
Anahtar Kavram
Amazon SQS Visibility Timeout
Alternatif Yöntem
The worker application can dynamically extend the visibility timeout of a specific message by calling the ChangeMessageVisibility API action if it detects that processing is taking longer than expected.
Tahmini Süre:1m 0s