An application uses an Amazon SQS standard queue to distribute image processing tasks to EC2 worker instances. Each worker instance takes approximately seconds to process a single task and then delete the message from the queue. Currently, the SQS queue's visibility timeout is set to seconds. The developer notices that worker instances are frequently processing the same image tasks multiple times. What should the developer do to resolve this issue?
- Increase the visibility timeout of the SQS queue to a value greater than seconds.Cevap
- BDecrease the visibility timeout of the SQS queue to seconds so messages are processed faster.
- CModify the application logic to reuse the SDK client's credentials rather than fetching them dynamically.
- DIncrease the timeout value of the AWS Lambda functions serving as the queue's consumers.
Cevap
Increase the visibility timeout of the SQS queue to a value greater than seconds.
The correct answer is to increase the visibility timeout of the SQS queue to a value greater than the worker's processing time. When a consumer receives a message from an SQS queue, the message remains in the queue but is hidden from other consumers for the duration of the visibility timeout. If the consumer does not delete the message within this period, it becomes visible again. Since the workers take seconds to process the task but the timeout is set to seconds, the message becomes visible and gets processed by other workers. Setting the timeout to a value greater than seconds prevents this overlap.
Adım Adım Çözüm
Anahtar Kavram
SQS Visibility Timeout vs Message Processing Time
Tahmini Süre:45s