AceReady
AWS
Question 1 of 13
Easy

When should you choose AWS Lambda over EC2 to host an application workload ?

Answer

EC2 provides classic virtual machines, where you manage the operating system, sizing and continuous availability yourself, giving full control but billing tied to instance uptime, whether it's used or not. Lambda is a serverless service that runs a function in response to a trigger, like an HTTP request or a queue message, with no server management, billing for actual execution time and automatic scaling down to zero when there are no calls. Lambda fits well for short, event-triggered processing, EC2 remains relevant for continuous workloads that need fine-grained control over the environment or execution durations longer than Lambda's limits allow.

Common trap

The trap is forgetting a Lambda function's execution duration limit and the cold start for an infrequently called function: long-running processing or a workload that needs consistently low latency, even after a period of inactivity, often fits EC2 or an always-on containerized service better.