Question

Difficulty: MediumMessage-Based Integration using Amazon SQS and SNS

An image processing application uses an Amazon SQS standard queue to decouple a web front-end from EC2 worker instances. The worker instances retrieve messages from the queue, download a high-resolution image from Amazon S3, perform CPU-intensive image compression, and upload the processed image back to S3. Currently, the SQS queue's default visibility timeout is configured to 3030 seconds. However, for large images, the compression process can take up to 22 minutes (120120 seconds). As a result, other worker instances frequently retrieve the same image message while it is still being processed by the first worker, leading to duplicate processing. Which of the following actions should the developer take to resolve this issue? (Select TWO.)

  1. Increase the default visibility timeout of the SQS queue to 150150 seconds.Answer
  2. Modify the worker application code to call the ChangeMessageVisibility API, extending the visibility timeout while the image is being processed.Answer
  3. C
    Set the DelaySeconds attribute of the SQS queue to 120120 seconds.
  4. D
    Increase the SQS queue's ReceiveMessageWaitTimeSeconds parameter to 120120 seconds.
  5. E
    Configure a dead-letter queue (DLQ) with the maxReceiveCount set to 11 on the source SQS queue.

Answer

Increase the default visibility timeout of the SQS queue to 150150 seconds, and modify the worker application code to call the ChangeMessageVisibility API to extend the visibility timeout while the image is being processed.
Increasing the default visibility timeout to 150150 seconds ensures the message remains hidden from other consumers for the duration of the 120120-second processing window. Alternatively, using the ChangeMessageVisibility API dynamically extends the visibility timeout during active processing, which is ideal for workloads with variable processing times. Both approaches prevent other workers from retrieving the message concurrently.

Step-by-Step Solution

1
Analyze the relationship between the processing duration and the queue's default visibility timeout.
The processing time (up to 120120 seconds) exceeds the default visibility timeout (3030 seconds), meaning the message becomes visible to other workers while processing is still ongoing.
To prevent duplicate processing, the visibility timeout must be longer than the maximum processing time.
2
Evaluate SQS queue configurations and API actions that can extend the visibility window.
Increasing the default visibility timeout on the queue (e.g., to 150150 seconds) or calling the ChangeMessageVisibility API during runtime can keep the message hidden.
These solutions directly keep the message invisible to other workers while the active worker completes the task.
3
Eliminate incorrect options that do not affect the post-retrieval visibility window.
DelaySeconds affects initial message ingestion delay, ReceiveMessageWaitTimeSeconds controls polling duration (max 2020 seconds), and DLQ configuration with maxReceiveCount of 11 prematurely discards messages.
These options represent common SQS configuration misconceptions and do not solve the processing timeout issue.

Key Concept

Amazon SQS Message Visibility Timeout management
Rate this question