Question

Difficulty: EasyMessage-Based Integration using Amazon SQS and SNS

A developer is implementing a game state update system where player level-up events are sent to an Amazon SQS queue. An AWS Lambda function is configured to consume messages from the queue and process the updates. The Lambda function has its timeout configured to 50 seconds. The SQS queue has a visibility timeout of 20 seconds. During testing, the developer notices that some level-up events are being processed multiple times by different Lambda invocations. Which configuration change will prevent the duplicate processing of these messages?

  1. Increase the visibility timeout of the Amazon SQS queue to at least 50 seconds.Answer
  2. B
    Increase the timeout of the AWS Lambda function to 90 seconds.
  3. C
    Decrease the visibility timeout of the Amazon SQS queue to 10 seconds.
  4. D
    Change the Lambda function's IAM execution role to have trust relationships with the SQS queue.

Answer

Increase the visibility timeout of the Amazon SQS queue to at least 50 seconds.
The correct option is to increase the visibility timeout of the Amazon SQS queue to at least 50 seconds. SQS visibility timeout prevents other consumers from receiving and processing a message that is currently being processed. If the consumer (the Lambda function) takes up to 50 seconds to complete, the visibility timeout must be at least 50 seconds so that the message remains invisible until the Lambda function successfully deletes it.

Step-by-Step Solution

1
Analyze the relationship between the consumer processing time (Lambda function timeout) and the queue configuration.
The Lambda function timeout is 50 seconds, meaning a single invocation can run for up to 50 seconds.
This establishes the maximum time a consumer requires to finish processing and delete a message.
2
Compare the processing time with the SQS visibility timeout.
The current SQS visibility timeout is 20 seconds, which is less than the 50-second processing time.
After 20 seconds, SQS makes the message visible to other consumers again, even though the original Lambda invocation is still running.
3
Determine the required adjustment to the visibility timeout.
The SQS visibility timeout must be increased to a value that is at least equal to the Lambda function timeout (50 seconds).
This ensures the message remains hidden from other consumers for the entire duration of the Lambda function execution, preventing duplicate processing.

Key Concept

Amazon SQS visibility timeout must be configured to be greater than or equal to the processing timeout of the consumer to prevent duplicate processing.
Estimated Time:1m 0s
Rate this question