A developer is implementing a background processing application on Amazon EC2 instances that retrieves and processes data batches from an Amazon SQS standard queue. Each batch processing operation takes approximately minutes to complete. During testing, the developer observes that multiple EC2 instances are processing the same data batches, causing duplicate records in the database. The SQS queue is currently using the default configuration values. Which of the following actions will resolve the duplicate processing issue?
- Increase the visibility timeout of the SQS queue to at least minutes.Cevap
- BDecrease the visibility timeout of the SQS queue to seconds.
- CRedesign the application to run on AWS Lambda with a function execution timeout set to minutes.
- DHardcode an IAM user's secret access key and access key ID within the SDK client initialization code to authenticate requests faster.
Cevap
Increase the visibility timeout of the SQS queue to at least minutes.
Increasing the SQS queue's visibility timeout ensures that a message remains invisible to other consumers for the entire duration of the processing logic ( minutes). Setting the timeout to a value greater than the processing time (such as minutes) allows the processing instance sufficient time to complete its task and delete the message from the queue.
Adım Adım Çözüm
Anahtar Kavram
SQS Visibility Timeout vs Consumer Processing Duration