Question

Difficulty: MediumMessage-Based Integration using Amazon SQS and SNS

A developer is implementing a medical imaging pipeline where scan metadata is published to an Amazon SNS topic. An Amazon SQS queue, which is subscribed to the topic, triggers an AWS Lambda function to generate detailed diagnostic reports. The Lambda function has a timeout of 9090 seconds, and a single report can take up to 8080 seconds to generate. During testing, the developer observes that several reports are being generated multiple times for the same scan.

Which configuration change should the developer make to resolve this duplicate processing issue?

  1. Increase the visibility timeout of the SQS queue to at least 540540 seconds.Answer
  2. B
    Set the visibility timeout of the SQS queue to 9090 seconds to match the Lambda function timeout.
  3. C
    Configure an SQS dead-letter queue (DLQ) with a maxReceiveCount of 11 on the main queue.
  4. D
    Increase the Lambda function timeout to 480480 seconds while leaving the queue settings at their defaults.

Answer

Increase the visibility timeout of the SQS queue to at least 540540 seconds.
The correct answer is to increase the SQS visibility timeout to at least 540540 seconds. According to AWS best practices for SQS-Lambda event source mappings, the queue's visibility timeout must be set to at least 6 times the Lambda function's timeout. This buffer allows the Lambda service to handle retries and throttling without immediately making the message visible to other concurrent execution environments.

Step-by-Step Solution

1
Analyze the cause of message duplication in SQS-Lambda integrations.
The Lambda function timeout is 9090 seconds, but the SQS default visibility timeout is 3030 seconds. When a processing job takes up to 8080 seconds, the default visibility timeout expires, making the message visible again in the queue while the original Lambda execution is still running.
Understanding the relationship between processing duration, SQS visibility timeout, and Lambda execution helps locate the misconfiguration.
2
Apply the AWS recommended formula for SQS visibility timeout when integrated with Lambda.
AWS recommends setting the SQS queue's visibility timeout to at least 6 times the timeout of the consuming Lambda function.
This configuration provides a buffer for Lambda to retry downstream calls if the function is throttled during event source mapping invocations.
3
Calculate the required visibility timeout.
90 seconds×6=540 seconds90 \text{ seconds} \times 6 = 540 \text{ seconds}.
Ensures that the queue's visibility timeout is configured to the correct minimum value based on the 9090-second Lambda timeout.

Key Concept

SQS Visibility Timeout configuration with AWS Lambda integration
Estimated Time:1m 30s
Rate this question