Soru

Zorluk: KolayMessage-Based Integration using Amazon SQS and SNS

An application uses an Amazon SQS standard queue to distribute image processing tasks to EC2 worker instances. Each worker instance takes approximately 1515 seconds to process a single task and then delete the message from the queue. Currently, the SQS queue's visibility timeout is set to 55 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?

  1. Increase the visibility timeout of the SQS queue to a value greater than 1515 seconds.Cevap
  2. B
    Decrease the visibility timeout of the SQS queue to 22 seconds so messages are processed faster.
  3. C
    Modify the application logic to reuse the SDK client's credentials rather than fetching them dynamically.
  4. D
    Increase 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 1515 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 1515 seconds to process the task but the timeout is set to 55 seconds, the message becomes visible and gets processed by other workers. Setting the timeout to a value greater than 1515 seconds prevents this overlap.

Adım Adım Çözüm

1
Analyze the relationship between processing duration and SQS visibility timeout.
The message processing takes 1515 seconds, but the visibility timeout is only 55 seconds.
When the visibility timeout is shorter than the processing time, the message becomes visible to other consumers in the queue before the current worker can finish processing and delete it.
2
Select the configuration adjustment that keeps the message hidden for the full processing duration.
Increase the SQS visibility timeout to a value greater than 1515 seconds.
This guarantees that the processing worker has enough time to complete the task and delete the message from the queue, preventing other workers from picking it up in the meantime.

Anahtar Kavram

SQS Visibility Timeout vs Message Processing Time
Tahmini Süre:45s
Bu soruyu puanla