
Ultimate access to all questions.
Answer-first summary for fast verification
Answer: Migrate the script on the EC2 instance to an AWS Lambda function with the appropriate runtime.
## Explanation **Correct Answer: C - Migrate the script on the EC2 instance to an AWS Lambda function with the appropriate runtime.** ### Why this is the correct answer: 1. **Cost Reduction**: AWS Lambda follows a pay-per-use pricing model where you only pay for the compute time consumed while processing messages. This eliminates the need to pay for idle EC2 instance time, which significantly reduces operational costs. 2. **Scalability**: Lambda automatically scales to handle a growing number of messages in the SQS queue. As more messages arrive, Lambda can process them concurrently without any manual intervention. 3. **SQS Integration**: AWS Lambda has native integration with Amazon SQS through event source mapping. Lambda can be configured to automatically poll the SQS queue and trigger function executions when messages are available. 4. **Maintains Processing Capability**: The solution maintains the ability to process messages while optimizing costs, meeting both requirements. ### Analysis of other options: **A. Increase the size of the EC2 instance to process messages faster.** - This would actually **increase** costs rather than reduce them, as larger EC2 instances are more expensive. - While it might process messages faster, it doesn't address the cost reduction requirement. **B. Use Amazon EventBridge to turn off the EC2 instance when the instance is underutilized.** - This could reduce costs when the instance is idle, but it creates operational complexity. - It doesn't handle the growing number of messages effectively - if messages arrive when the instance is off, they won't be processed until the instance is restarted. - This approach requires additional monitoring and automation setup. **D. Use AWS Systems Manager Run Command to run the script on demand.** - This would require manual intervention or additional automation to trigger script execution. - It doesn't provide automatic scaling for growing message volumes. - The EC2 instance would still need to be running to execute the script, maintaining infrastructure costs. ### Key AWS Services Concepts: - **AWS Lambda**: Serverless compute service that automatically scales and charges only for compute time used. - **SQS Event Source Mapping**: Allows Lambda to poll SQS queues and automatically trigger function executions when messages are available. - **Cost Optimization**: Lambda eliminates the need to provision and pay for idle compute capacity, aligning perfectly with the requirement to reduce operational costs while maintaining processing capability.
Author: LeetQuiz Editorial Team
No comments yet.
A company uses an Amazon EC2 instance to run a script to poll for and process messages in an Amazon Simple Queue Service (Amazon SQS) queue. The company wants to reduce operational costs while maintaining its ability to process a growing number of messages that are added to the queue.
What should a solutions architect recommend to meet these requirements?
A
Increase the size of the EC2 instance to process messages faster.
B
Use Amazon EventBridge to turn off the EC2 instance when the instance is underutilized.
C
Migrate the script on the EC2 instance to an AWS Lambda function with the appropriate runtime.
D
Use AWS Systems Manager Run Command to run the script on demand.