Question

Difficulty: HardMessage-Based Integration using Amazon SQS and SNS

An enterprise applications developer is troubleshooting a batch processing pipeline. An Amazon SQS standard queue receives transaction messages, which trigger an AWS Lambda function. The Lambda function's timeout is set to 9090 seconds. Under heavy load, the developer observes that several messages are being processed multiple times by concurrent Lambda executions, resulting in duplicate database entries. Analysis of the logs shows that the Lambda function is executing successfully without timing out or throwing errors.

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

  1. A
    Configure the SQS queue's visibility timeout to 90 seconds to match the Lambda function's timeout exactly.
  2. B
    Deploy the Lambda function in a private VPC subnet without a NAT Gateway to isolate network connectivity.
  3. Increase the SQS queue's visibility timeout to at least 540 seconds.Answer
  4. D
    Decrease the Lambda function's timeout to 15 seconds and store transaction logs in global variables to optimize execution context reuse.

Answer

Increase the SQS queue's visibility timeout to at least 540 seconds.
Increasing the SQS queue's visibility timeout to at least 540 seconds is correct because AWS best practices dictate that the visibility timeout of the source queue must be at least 6 times the timeout of the triggering Lambda function. For a 9090-second function timeout, this is calculated as 6×90=5406 \times 90 = 540 seconds. This safety window allows the Lambda function to safely complete its processing and delete the message without the message becoming visible to other concurrent consumers.

Step-by-Step Solution

1
Analyze the relationship between the Lambda function's timeout and the SQS queue's visibility timeout.
The Lambda function has a timeout of 9090 seconds, meaning its execution can take up to 9090 seconds.
To identify why messages are being reprocessed before the current Lambda function execution can complete and delete them.
2
Apply AWS integration recommendations for SQS event sources.
AWS recommends setting the SQS queue's visibility timeout to at least 66 times the timeout of the triggering Lambda function.
This configuration provides a safety margin (6×90=5406 \times 90 = 540 seconds) to accommodate processing delays, cold starts, and Lambda-managed retries.
3
Select the correct configuration change to prevent duplicate execution.
Configuring the SQS visibility timeout to at least 540540 seconds ensures the message remains hidden until the execution completes.
To ensure that SQS does not make the message visible to other polling instances while the current execution is still active.

Key Concept

SQS Visibility Timeout vs Lambda Function Timeout
Estimated Time:2m 0s
Rate this question