Exam SAP-C02 All QuestionsBrowse all questions from this exam
Question 68

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?

    Correct Answer: A

    Migrating the data processing script to an AWS Lambda function and using an S3 event notification to invoke the Lambda function to process the objects when the company uploads the objects is the most cost-effective solution. Lambda is serverless, which means there is no need to manage any infrastructure. It automatically scales based on the number of requests, ensuring high availability and scaling capabilities. The pay-per-use pricing model of Lambda will likely be more cost-effective for this workload compared to running an EC2 instance or managing ECS containers, especially considering that the script runs for only 5 minutes every 10 minutes. This approach also minimizes long-term management overhead.

Discussion
masetromainOption: A

The correct answer is A, migrating the data processing script to an AWS Lambda function and using an S3 event notification to invoke the Lambda function to process the objects when the company uploads the objects. This solution meets the company's requirements of high availability and scalability, as well as reducing long-term management overhead, and is likely to be the most cost-effective option. Option B involves creating an SQS queue and configuring S3 to send event notifications to it. The data processing script would then poll the SQS queue and process the S3 objects that the SQS message identifies. While this option also provides high availability and scalability, it is less cost-effective than using Lambda, as it requires additional resources such as an SQS queue and an EC2 Auto Scaling group.

masetromain

Option C, migrating the data processing script to a container image and running it on an EC2 instance, would still require the company to manage the underlying EC2 instances and may not be as cost-effective as using Lambda. Option D, migrating the data processing script to a container image that runs on Amazon ECS on AWS Fargate, would still require the company to manage the underlying infrastructure and may not be as cost-effective as using Lambda. Additionally, it introduces additional complexity by adding a Lambda function that calls the Fargate RunTask API operation.

red_panda

ECS in Fargate mode you don't need to manage anything underling infra! You're totally forgot about cost, for sure running an ECS Fargate has lower cost than running a Lambda for 5 minutes every 10 minutes! Also the function to trigger the ECS workload (in option D), running for milliseconds (as need only to notify the doc upload in S3), so it's more correct the D answer. Ask to any Gen AI model, you will have mine answer with more details :)

NirvanaSNM

Use an S3 event notification to invoke the Lambda function to process the objects

hamimelon

Agree. Also, it says the company does not wanna manage long-term overhead, which points to serverless.

dpatra

SQS is out of the question because the script already has a built in logic that will prevent it to reprocess a message that's already been processed

zhangyu20000

A is correct, it provide HA, scale, less management. Task only need 5 minutes B: enen more complex C: container still run on one EC2, not scale d: need container, Farget and Lambda. Complex than A

covabix879Option: D

https://blogs.perficient.com/2021/06/17/aws-cost-analysis-comparing-lambda-ec2-fargate/ Even Fargate running continuosly is cheaper than Lambda running half of the time. So long running work load not cost effective with Lambda ( Every 10 minutes run for 5 minutes. So half of the time lambda is running) Therefore Fargate is the most cost-effective solution.

ShenanniganOption: A

The answer is A: AWS Pricing Calculator (using: 10,000 request per month, 300,000 ms which = 5 minutes 128 MB of Memory 512 MB of Storage ) Amount of memory allocated: 128 MB x 0.0009765625 GB in a MB = 0.125 GB Amount of ephemeral storage allocated: 512 MB x 0.0009765625 GB in a MB = 0.5 GB Pricing calculations 10,000 requests x 300,000 ms x 0.001 ms to sec conversion factor = 3,000,000.00 total compute (seconds) 0.125 GB x 3,000,000.00 seconds = 375,000.00 total compute (GB-s) 375,000.00 GB-s x 0.0000166667 USD = 6.25 USD (monthly compute charges) 10,000 requests x 0.0000002 USD = 0.00 USD (monthly request charges) 0.50 GB - 0.5 GB (no additional charge) = 0.00 GB billable ephemeral storage per function Lambda costs - Without Free Tier (monthly): 6.25 USD For those thinking D is the cheaper option, do you really believe ECS Fargate would be cheaper?

red_pandaOption: D

Ok i was thinking between A and D. I'm pretty sure which is D our answer, see the details. The requirements are: - COST as much as possible low - OPERATIONS as much as possible managed. So at the first reading, the A option seems to be the correct option (because it's totally AWS managed), but here we're totally forgot the cost. Running a Lambda function, for 5 minutes every 10 minutes, it's very very more expensive than a simple ECS task running continously. Finally, ECS in fargate mode is totally AWS managed, so we will have lower cost, and a serverless and HA environment, which auto-scale if we need more processing at time. For me, option D is the correct answer.

LazyAutonomyOption: D

100% the answer is D. 5 minutes to process EACH FILE? And the EC2 instance is processing files 60% of the time? Lambda would be crazy expensive in this scenario. ECS/Fargate = cheaper for sure. See link in @covabix879 comment for proof of this. Greyeye said something rather ridiculous: "If you get 1000 images, you will see 1000 tasks. That is not economical or cheap." How can 1x EC2 instance running a script every 10 minutes process 1000 images with each one taking 5 minutes? Even if the script processed images in parallel, e.g. one image per vCPU at a time, that instance would need 500 vCPUs! For the EC2 instance to be idle 40% of the time, it would need 833 vCPUs. That's ridiculous. But even if 1000 images suddenly appeared, the Lambda solution would still result in 1000 Lambdas all firing and running for 5 minutes each. Which is going to be more expensive than ECS/Fargate.

kjcncjek

running lambda for 5 minutes is not cost effective, so answer is D

zolthar_zOption: A

A, the company wants to reduce management overhead not costs, we should stay with the question requirement, it doesn't said anything about cost, probably D will be cheaper but the solution must resolve the question necessity and is reduce long-term management overhead

HelpnosenseOption: D

I vote D because the service is from EC2 to lambda and work is processing data. Without given how big is the data we can't assume that the data is always below the lambda ephemeral storage limit 0.5GB. Nowadays, a file can easily break 0.5GB. While D is still EC2 based so whatever previous EC2 can do farget can do as well.

gofavad926Option: A

A, use lambda function is much cost-effective than use ECS Margate

8608f25Option: A

Option A is the most cost-effective and efficient solution. AWS Lambda allows for running code in response to triggers such as S3 event notifications without the need to manage servers, thereby directly addressing the requirement to reduce long-term management overhead. Since the script is only needed when new files are uploaded and takes about 5 minutes to process each file, Lambda’s ability to scale automatically and its billing model based on actual compute time used make it an ideal solution. Lambda can process files immediately upon upload, maximizing efficiency and minimizing idle time. Option D proposes using Amazon ECS on AWS Fargate with Lambda to trigger tasks. This solution introduces container orchestration, which can improve scalability and reduce some management overhead. However, it is not as cost-effective as directly invoking a Lambda function to process files, considering the lightweight nature of the task and the added complexity of managing container orchestration and Lambda functions together.

ninomfr64Option: A

A = correct B = does not reduce long-term management overhead C = does not reduce long-term management overhead D = does not reduce long-term management overhead Note: D is a cheap options as mentioned by other here below could be cheaper than A. However, in addition to maintaining the script code it requires to maintain the container image and the lambda

severlightOption: A

in the real world it might be D, but with provided details and keeping in mind lambda retries in case of A, I would vote for A.

Sandeep_BOption: A

D is more complex and overload for administration. Hence Vote for A

GreyeyeOption: A

I vote A D will invoke a new Fargate task per every PUT command. If you get 1000 images, you will see 1000 tasks. That is not economical or cheap. if D was invoking a new task by other means like EventBridge, this would have been a lot cheaper.

CuteRunRunOption: A

I prefer A

chico2023Option: A

I would go with A as well. According to Olabiba: "Yes, option A would generally be more cost-effective than option D. In option A, you would migrate the data processing script to an AWS Lambda function, which has a pay-per-use pricing model. You would only pay for the actual number of requests and the duration of the function execution. This can be more cost-effective for short-duration tasks like processing files. On the other hand, in option D, you would migrate the data processing script to a container image that runs on Amazon Elastic Container Service (Amazon ECS) on AWS Fargate. Fargate has a different pricing model, where you pay for the vCPU and memory resources allocated to your containers. This can be more expensive compared to the pay-per-use model of AWS Lambda."