Question

Difficulty: MediumMessage-Based Integration using Amazon SQS and SNS

A developer is designing a document processing system. User-uploaded documents are published to an Amazon SNS topic. Two Amazon SQS queues are subscribed to the topic: Queue A feeds a text-extraction service running on Amazon ECS, which takes up to 45 seconds to process each document, while Queue B feeds an archiving service. During high-load periods, the text-extraction service experiences two problems: many documents are processed multiple times by different ECS tasks, and SQS messages sent to Queue A are occasionally discarded before being processed because the ECS task scale-up takes longer than the queue's default message age limit. Which TWO actions should the developer take to resolve these issues? (Select TWO.)

  1. Increase the VisibilityTimeout attribute of Queue A to a value greater than the maximum document processing time, such as 60 seconds.Answer
  2. Increase the MessageRetentionPeriod attribute of Queue A to a higher value, such as 4 days.Answer
  3. C
    Decrease the VisibilityTimeout attribute of Queue A to 15 seconds to ensure that unprocessed messages are quickly made available to other ECS tasks.
  4. D
    Enable Content-Based Deduplication on Queue A to automatically filter out duplicate message deliveries.
  5. E
    Set the SNS subscription delivery policy retry backoff to 45 seconds to throttle message delivery to Queue A.

Answer

The developer should increase the VisibilityTimeout attribute of Queue A to a value greater than the maximum document processing time (such as 60 seconds) and increase the MessageRetentionPeriod attribute of Queue A to a higher value (such as 4 days).
Increasing the SQS visibility timeout to a value larger than the consumer processing time ensures that the consumer can complete the task and delete the message before another consumer picks it up. Increasing the message retention period ensures that messages stay in the queue during scaling delays instead of being discarded.

Step-by-Step Solution

1
Analyze the duplicate processing issue.
The text-extraction service takes up to 45 seconds, which exceeds the default SQS visibility timeout of 30 seconds. While a task is processing, the visibility timeout expires and the message returns to the queue, allowing another task to poll and process it.
To resolve this, the visibility timeout must be set to a value greater than the maximum processing time.
2
Analyze the message loss issue.
Delayed ECS task scaling causes messages to age out and get discarded before they can be consumed. SQS deletes messages that exceed their configured retention period (default 4 days, but can be configured lower).
Increasing the message retention period gives the auto-scaling group enough time to launch new instances/tasks and process the backlog.

Key Concept

Configuring SQS Visibility Timeout and Message Retention Period for Consumer Capacity Alignment
Rate this question