A developer is designing an IoT home alert system. When a sensor detects an anomaly, it publishes a message to an Amazon SNS topic. An Amazon SQS queue is subscribed to this topic to buffer messages for an AWS Lambda function that processes alerts and notifies users. The Lambda function takes up to seconds to process a single message and send notifications. Currently, the SQS queue's Visibility Timeout is set to seconds, and the Lambda function's timeout is set to seconds. Users are receiving duplicate alert notifications for the same event. Which modification should the developer make to resolve the duplicate notifications?
- AIncrease the Amazon SQS queue's visibility timeout to seconds so that it exceeds the maximum processing time of the alert function.
- BDecrease the AWS Lambda function's timeout to seconds to match the current Amazon SQS visibility timeout configuration.
- Increase the Amazon SQS queue's visibility timeout to seconds to satisfy the recommendation of being at least 6 times the Lambda function's timeout.Answer
- DModify the AWS Lambda function code to initialize a new Amazon SQS client with hardcoded administrator AWS access keys to delete the message immediately upon invocation.
Answer
Increase the Amazon SQS queue's visibility timeout to seconds to satisfy the recommendation of being at least 6 times the Lambda function's timeout.
Increasing the Amazon SQS queue's visibility timeout to seconds matches the AWS recommendation of setting the visibility timeout to at least 6 times the Lambda function's timeout ( seconds). This prevents duplicate message processing by ensuring the message is not visible to other consumers while the Lambda function is executing or retrying.
Step-by-Step Solution
Key Concept
Configuring SQS Visibility Timeout for Lambda Event Source Mapping