Soru

Zorluk: OrtaMessage-Based Integration using Amazon SQS and SNS

A developer is implementing a background worker service on Amazon ECS to process batch image transcoding jobs from an Amazon SQS standard queue. The average transcoding job takes 4 minutes to complete, but high-resolution images can take up to 12 minutes. During testing, the developer observes that multiple ECS tasks are frequently processing the same image file concurrently, resulting in duplicate outputs and wasted compute resources. Additionally, corrupt image files that fail to transcode are retried indefinitely, blocking the queue.

Which combination of configuration steps should the developer perform to resolve these issues? (Select TWO.)

  1. Set the SQS queue's visibility timeout to a value greater than 12 minutes to allow sufficient time for transcoding to complete before the message is made available to other tasks.Cevap
  2. Configure a dead-letter queue (DLQ) and specify a redrive policy on the source SQS queue with a maxReceiveCount value to capture and isolate consistently failing messages.Cevap
  3. C
    Decrease the visibility timeout of the SQS queue to 1 minute to ensure that if a task fails, another ECS task can immediately pick up the message.
  4. D
    Increase the task execution timeout of the ECS tasks to 15 minutes without modifying the SQS queue parameters.
  5. E
    Hardcode an IAM user access key and secret key inside the worker application code when constructing the AWS SDK client to reduce the latency of credentials retrieval.

Cevap

Configure the SQS queue's visibility timeout to a value greater than 12 minutes, and set up a dead-letter queue (DLQ) with a redrive policy and maxReceiveCount on the main SQS queue to isolate failing messages.
To prevent duplicate processing of messages, the SQS visibility timeout must be configured to be longer than the maximum time it takes for a consumer to process a message. This ensures the message remains hidden from other consumers while the active worker completes its task. To handle corrupt or unprocessable messages that would otherwise block the queue indefinitely, a dead-letter queue (DLQ) must be configured with a redrive policy using a maxReceiveCount parameter to isolate these messages after a set number of failures.

Adım Adım Çözüm

1
Analyze the cause of duplicate processing.
The average processing time is 4 minutes, and the maximum is 12 minutes. If the queue's visibility timeout is set to a value less than the processing time, another consumer will poll the queue and retrieve the same message before the active task can finish and delete it.
To prevent duplicate processing, the visibility timeout of the queue must exceed the maximum time the consumer takes to process the message.
2
Address the infinite retry issue for corrupt or invalid messages.
Corrupt messages that consistently fail to process should be sent to a dead-letter queue (DLQ) rather than returning to the main queue indefinitely.
Using a redrive policy with a set maxReceiveCount separates failing messages from successful ones, preventing queue blockages.

Anahtar Kavram

SQS visibility timeout configuration and dead-letter queue (DLQ) handling
Bu soruyu puanla