Amazon Web Services
Containers — ECS, EKS & Fargate
Run containers as managed services, with or without managing the underlying servers.
Two independent choices: which orchestrator, and who runs the machines.
ECS vs EKS is choosing between a house-brand appliance that just works (ECS) and an industry-standard one with a huge accessory ecosystem (EKS/Kubernetes). EC2 vs Fargate is owning the building your machines sit in versus renting fully-serviced space and only paying for the machines.
Key Concepts
1
orchestrator ECS (AWS-native) or EKS (Kubernetes)
compute Fargate (serverless) or EC2 (your instances)2
Any combination is valid, which is why the question has four answers rather than two.
3
ECS is simpler and AWS-shaped.
task definition containers, CPU, memory, ports, IAM role
task one running copy of that definition
service keeps N tasks running behind a load balancer4
EKS is upstream Kubernetes with a managed control plane. You get the ecosystem — Helm, operators,
portability — and the operational weight that comes with it. There is also a per-cluster hourly charge that
ECS does not have.
5
Fargate removes the instances. You declare CPU and memory per task; AWS places and runs it. No AMI, no
patching, no capacity to plan. You pay per task per second, at a premium over EC2.
6
EC2 launch type keeps control. Cheaper at steady scale, allows GPUs, daemon containers and custom
kernels, and makes bin-packing your problem.
7
How to choose, plainly.
starting out, AWS-only ECS on Fargate
already have Kubernetes skills EKS
multi-cloud or portability EKS
large steady fleet, cost-tuned EC2 launch type
spiky or small workloads Fargate8
Each task gets its own IAM role, which is the right pattern: no shared instance credentials, and
permissions scoped to the one service.
9
Tasks are placed across AZs by the service scheduler, and a load balancer target group registers and
drains them — which is what makes a rolling deploy invisible.
10
The common misconception. Fargate is not slower than EC2 for the same CPU allocation; it is more
expensive per unit and removes an entire category of work.
11
What the interviewer is probing.1. "ECS or EKS?" Probing: whether the answer is reasoned or fashionable. Stalls: "EKS,
Kubernetes is standard." Moves up: ECS when you want AWS-native simplicity; EKS when you need the
Kubernetes API, operators and portability, and can carry the operational weight.
12
2. "What does Fargate remove, and what does it cost?" Probing: the trade. Stalls: "It is
just easier." Moves up: no instances to size, patch or bin-pack, billed per task — at a premium
per unit of CPU compared with EC2 at steady scale.
13
3. "How should a task authenticate to AWS services?" Probing: the right identity model.
Stalls: "Environment variables with keys." Moves up: a task role, so each service gets its own
scoped credentials that rotate automatically and nothing is stored.
14
4. "How does a rolling deploy avoid dropped requests?" Probing: draining. Stalls: "It just
replaces tasks." Moves up: the target group deregisters the task and waits out the deregistration
delay so in-flight requests finish before it stops.