Comparison lab
Amazon EC2 vs AWS Lambda vs AWS Fargate
EC2 runs a machine. Lambda runs a function. Fargate runs a container.
Picture the difference
Workload → virtual machine (EC2) / short function invocation (Lambda) / managed container compute (Fargate)
| Option | What it does | Exam clue | When not to use it |
|---|---|---|---|
| Amazon EC2 | On-demand virtual machines with control over the operating system, instance type, and network placement. | virtual machine, instance types, AMI, guest OS, root access | Do not assume AWS patches the guest OS, or choose a VM when an event handler needs no host control. |
| AWS Lambda | Serverless function compute that runs code in response to events or direct invocation. | functions, event-driven, invocation, concurrency, 15-minute timeout | Do not choose it for jobs that cannot finish within the invocation limit or for software that must control the OS. |
| AWS Fargate | Serverless compute capacity for running Amazon ECS tasks and supported Amazon EKS pods without managing worker instances. | serverless containers, ECS tasks, EKS pods, no host management, CPU and memory | Do not choose it for host-level control, or confuse container compute with a function that runs only for an invocation. |
Decision tree
- Need control of the guest OS, including custom kernel modules Amazon EC2
- Run short-lived code in response to events without managing servers AWS Lambda
- Run ECS tasks or EKS pods without managing worker instances AWS Fargate
If none of these clues fit, check the exact requirement before choosing.