Question

Difficulty: HardServerless Development with AWS Lambda

A developer is configuring a serverless application where an AWS Lambda function processes messages from an Amazon SQS queue. The function performs CPU-intensive video transcoding that takes up to 33 minutes to complete per message. During initial testing, the Lambda function's timeout is set to the default of 1515 seconds, resulting in execution timeouts. Additionally, the developer needs to prevent messages from being received and processed multiple times by other concurrent Lambda invocations while a message is currently being processed. Which configuration changes will resolve the execution timeouts and prevent duplicate message processing?

  1. Configure the Lambda function's timeout to 180180 seconds, and set the Amazon SQS queue's visibility timeout to at least 10801080 seconds.Answer
  2. B
    Configure the Lambda function's timeout to 180180 seconds, and set the Amazon SQS queue's visibility timeout to 3030 seconds.
  3. C
    Configure the Lambda function's timeout to 1515 seconds, and set the Amazon SQS queue's visibility timeout to 9090 seconds.
  4. D
    Configure the Lambda function's timeout to 10801080 seconds, and set the Amazon SQS queue's visibility timeout to 180180 seconds.

Answer

Configure the Lambda function's timeout to 180180 seconds, and set the Amazon SQS queue's visibility timeout to at least 10801080 seconds.
The correct configuration is to set the Lambda function's timeout to 180180 seconds (to accommodate the 33-minute processing time) and the SQS visibility timeout to at least 10801080 seconds. According to AWS best practices, the visibility timeout of an SQS queue triggering a Lambda function should be configured to at least 66 times the Lambda function's timeout to prevent message processing loops and duplication due to throttling or retries.

Step-by-Step Solution

1
Analyze the processing time requirement of the backend task.
The video transcoding task requires up to 33 minutes (180180 seconds) to complete. The Lambda function's timeout must be set to at least 180180 seconds to prevent execution failures.
If the Lambda function's timeout is shorter than the task execution time, the environment terminates the execution before completion, causing the task to fail.
2
Determine the required SQS queue visibility timeout configuration.
The visibility timeout of the SQS queue must be set to at least 66 times the timeout of the Lambda function, which is 6×1806 \times 180 seconds = 10801080 seconds.
AWS recommends setting the SQS visibility timeout to at least 66 times the Lambda function timeout. This provides a safety margin so that if a Lambda function is throttled or fails, the message does not immediately become visible to other consumers before the current invocation finishes or retries.

Key Concept

AWS Lambda integration with Amazon SQS and visibility timeout configuration guidelines
Estimated Time:2m 0s
Rate this question