
Answer-first summary for fast verification
Answer: Migrate the data processing script to an AWS Lambda function. Use an S3 event notification to invoke the Lambda function to process the objects when the company uploads the objects.
1. **Explanation for Answer A:** - AWS Lambda is a serverless compute service that runs your code in response to events and automatically manages the compute resources for you. In this scenario, migrating the data processing script to an AWS Lambda function can help reduce the idle time of the EC2 instance. - By using an S3 event notification to trigger the Lambda function, the script will automatically process the files as soon as they are uploaded to the S3 bucket. This eliminates the need for the EC2 instance to poll the bucket, thus making the workload more efficient and reducing the idle time. - Since Lambda functions scale automatically by running code in response to each trigger, there is no need to manage scaling or availability manually. This reduces the long-term management overhead and can be more cost-effective, as you pay only for the compute time you consume. 2. **Why other options are not the most cost-effective:** - Option B involves using Amazon SQS and an EC2 Auto Scaling group. While this can improve scalability, it still requires managing EC2 instances and may not be as cost-effective as a serverless solution like Lambda. - Option C suggests using a container image on an EC2 instance, which still requires managing the EC2 instances and does not inherently improve the scalability or availability of the workload. - Option D involves using Amazon ECS on AWS Fargate with a Lambda function. While this is a scalable and serverless solution, it may be more complex and potentially more expensive than using Lambda directly with S3 event notifications.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
A company runs a Python script on an Amazon EC2 instance to process data. The script runs every 10 minutes. The script ingests files from an Amazon S3 bucket and processes the files. On average, the script takes approximately 5 minutes to process each file The script will not reprocess a file that the script has already processed. The company reviewed Amazon CloudWatch metrics and noticed that the EC2 instance is idle for approximately 40% of the time because of the file processing speed. The company wants to make the workload highly available and scalable. The company also wants to reduce long-term management overhead. Which solution will meet these requirements MOST cost-effectively?
A
Migrate the data processing script to an AWS Lambda function. Use an S3 event notification to invoke the Lambda function to process the objects when the company uploads the objects.
B
Create an Amazon Simple Queue Service (Amazon SQS) queue. Configure Amazon S3 to send event notifications to the SQS queue. Create an EC2 Auto Scaling group with a minimum size of one instance. Update the data processing script to poll the SQS queue. Process the S3 objects that the SQS message identifies.
C
Migrate the data processing script to a container image. Run the data processing container on an EC2 instance. Configure the container to poll the S3 bucket for new objects and to process the resulting objects.
D
Migrate the data processing script to a container image that runs on Amazon Elastic Container Service (Amazon ECS) on AWS Fargate. Create an AWS Lambda function that calls the Fargate RunTaskAPI operation when the container processes the file. Use an S3 event notification to invoke the Lambda function.
No comments yet.