Q84 — AWS SAA-C03 Ch.14

Question 84 of 100 | ← Chapter 14

Q1084. 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 overhead while maintaining its ability to process an increasing number of messages that are added to the queue.Which solution will meet these requirements?

Correct Answer: C. Migrate the script on the EC2 instance to an AWS Lambda function with an event source of the SQS queue.

Explanation

To determine the best solution for reducing operational overhead while maintaining the ability to process an increasing number of messages in an Amazon Simple Queue Service (Amazon SQS) queue, let's evaluate each option:A. Increase the size of the EC2 instance to process messages in the SQS queue faster.This approach might help with processing speed but doesn't address the operational overhead. Managing and scaling EC2 instances can be complex and requires handling aspects like instance monitoring, scaling policies, and potential downtime during scaling events.B. Configure an Amazon EventBridge rule to turn off the EC2 instance when the SQS queue is empty.This solution aims to reduce costs by turning off the EC2 instance when not in use. However, it doesn't address the need for scalability. When messages start flowing again, the EC2 instance would need to be turned back on, which introduces latency and overhead.C. Migrate the script on the EC2 instance to an AWS Lambda function with an event source of the SQS queue.This option is well-suited for the problem. AWS Lambda automatically scales with the number of incoming messages. You don't need to manage servers, and Lambda functions can be triggered directly by SQS messages. This approach reduces operational overhead significantly and can handle an increasing number of messages seamlessly.D. Configure an AWS Systems Manager Run Command to run the script on demand.This solution is more suitable for running scripts or commands on EC2 instances on an ad-hoc basis. It doesn't provide the automatic scaling or reduction in operational overhead that the problem requires.Based on the evaluation, the best solution is:C. Migrate the script on the EC2 instance to an AWS Lambda function with an event source of the SQS queue.This option meets the requirements of reducing operational overhead and maintaining the ability to process an increasing number of messages efficiently.