What are the core AWS compute services and how do you choose between EC2, ECS, Lambda and Fargate?
Four levels of abstraction, and the guidance is to choose the highest one that meets the requirement.
- EC2 — virtual machines. You manage the operating system, patching, scaling groups, and load balancing. Maximum control and maximum operational burden. Use it for legacy applications, workloads needing specific OS configuration or licensing, or long-running processes that do not containerise well.
- ECS / EKS — container orchestration. ECS is AWS-native and simpler; EKS is managed Kubernetes, portable but with real operational overhead. Use them when you have multiple services to schedule and genuine orchestration needs.
- Fargate — a serverless compute engine for ECS and EKS. You define CPU and memory per task and AWS runs it; there are no instances to patch or scale. Use it when you want containers without managing a cluster of hosts, which covers most container workloads.
- Lambda — event-driven functions. You supply code, AWS handles everything else, scaling to zero and charging per invocation and duration. Use it for event processing, APIs with variable traffic, scheduled jobs, and glue between services.
Lambda's constraints matter: a 15-minute maximum execution time, cold starts affecting latency-sensitive paths, and a concurrency limit. It is excellent for spiky, short work and a poor fit for sustained high-throughput processing, where it can also be more expensive than containers.





