A developer is designing a messaging architecture for a smart thermostat application. The application publishes temperature alert messages to an Amazon SNS topic. The developer needs to process these alerts using an AWS Lambda function. The solution must ensure that no alerts are lost if the Lambda function experiences a sudden surge in invocations and is throttled.
Which two configuration steps should the developer perform to meet these requirements?
- Create an Amazon SQS queue and subscribe the queue to the Amazon SNS topic.Answer
- Configure the AWS Lambda function to consume messages from the Amazon SQS queue.Answer
- CConfigure the SQS queue's visibility timeout to be shorter than the Lambda function's timeout to accelerate message processing.
- DSet the AWS Lambda function's execution timeout to be greater than the SQS queue's visibility timeout to prevent Lambda timeout errors.
- EInitialize the Amazon SQS client inside the Lambda function using hardcoded IAM user access keys.
Answer
Create an Amazon SQS queue and subscribe the queue to the Amazon SNS topic, and configure the AWS Lambda function to consume messages from the Amazon SQS queue.
To handle sudden spikes and prevent message loss when Lambda is throttled, the developer should create an Amazon SQS queue and subscribe it to the Amazon SNS topic. Then, the Lambda function should be configured to consume from the SQS queue. This architecture buffers incoming traffic in the queue, allowing Lambda to process them reliably as execution capacity allows.
Step-by-Step Solution
Key Concept
Decoupling and buffering message processing using the SNS-to-SQS fanout pattern to handle downstream consumer throttling.
Estimated Time:1m 0s