ECS EC2 vs Fargate Cost Comparison
The ECS on EC2 vs ECS on Fargate decision is usually not “which list price is lower”. It is about utilization, packing efficiency, and how much you pay for idle capacity. After compute, the winner is often decided by logs, load balancers, and networking.
Step 1: normalize the workload (use average, not peak)
- Average running tasks over the month (baseline + busy month scenario).
- CPU and memory usage distribution (p50/p95), not just requests/limits.
- Traffic shape: steady, bursty, or scheduled down (non-prod scheduling matters).
Step 2: compute-only baseline (then stop)
Compute-only is a useful baseline, but it rarely predicts the total bill. Use it as step zero, then add the line items that dominate.
Step 3: what changes the math (the real decision drivers)
| Driver | EC2 | Fargate |
|---|---|---|
| Idle capacity | You pay for idle instances unless you can schedule down or pack workloads | You usually pay only for running tasks |
| Packing efficiency | High packing reduces cost dramatically | Packing is per-task; fragmentation can still exist |
| Ops overhead | You manage instances, scaling, AMIs, patching | Less infra management, faster iteration |
Step 4: add the line items that often dominate ECS bills
- Load balancers: hourly + capacity units for each ALB/NLB.
- Logs: ingestion + retention baseline (and scans during incidents).
- Networking: NAT processed GB, internet egress, and cross-AZ transfer.
- Storage: EBS and snapshots for EC2 services that attach volumes.
Worked example (why utilization dominates)
If EC2 runs at 30% average utilization due to fragmentation and headroom, you are paying ~3.3× the effective compute you need. If you can pack to 70% utilization, the EC2 model can become very competitive.
- EC2 at 30% utilization -> effective “paid capacity” multiplier ~ 1 / 0.30 ~= 3.3×
- EC2 at 70% utilization -> multiplier ~ 1 / 0.70 ~= 1.4×
Practical guidance
- Prefer ECS on EC2 when workloads are steady and you can pack well (and/or apply commitments).
- Prefer Fargate when workloads are spiky, you cannot keep EC2 utilization high, or you want simpler operations.
- Re-evaluate after measuring non-compute line items (logs, NAT, load balancers) for a real week.
Validation checklist
- Measure average and p95 task CPU/memory usage for a representative week.
- Measure how many load balancers exist and whether they are shared.
- Measure log ingestion GB/day and retention; validate query scan behavior during incidents.
- Measure NAT processed GB and egress GB for the traffic path your service actually uses.
Sources
- ECS pricing: aws.amazon.com/ecs/pricing
- Fargate pricing: aws.amazon.com/fargate/pricing
Related guides
AWS ECS Pricing & Cost Guide (EC2 vs Fargate drivers)
ECS cost model for compute, storage, and networking. Compare EC2 vs Fargate and identify real cost drivers.
Fargate vs EC2 cost: how to compare compute, overhead, and hidden line items
A practical Fargate vs EC2 cost comparison: normalize workload assumptions, compare unit economics (vCPU/memory-hours vs instance-hours), and include the line items that change the answer (idle capacity, load balancers, logs, transfer).
Lambda vs Fargate cost: a practical comparison (unit economics)
Compare Lambda vs Fargate cost with unit economics: cost per 1M requests (Lambda) versus average running tasks (Fargate), plus the non-compute line items that often dominate (logs, load balancers, transfer).
AWS Fargate pricing (cost model + pricing calculator)
A practical Fargate pricing guide and calculator companion: what drives compute cost (vCPU-hours + GB-hours), how to estimate average running tasks, and the non-compute line items that usually matter (logs, load balancers, data transfer).
ECS cost model beyond compute: the checklist that prevents surprise bills
A practical ECS cost model checklist beyond compute: load balancers, logs/metrics, NAT/egress, cross-AZ transfer, storage, and image registry behavior. Use it to avoid underestimating total ECS cost.
Fargate cost optimization (high-leverage fixes)
A practical Fargate cost optimization checklist: rightsize tasks, scale on real signals, reduce idle capacity, and avoid hidden networking and logging costs.
FAQ
When is ECS on EC2 cheaper than ECS on Fargate?
EC2 often wins for steady workloads when you can keep instances highly utilized, pack services efficiently, and apply commitments.
When is ECS on Fargate cheaper than ECS on EC2?
Fargate can win when workloads are spiky or uncertain and EC2 would be underutilized (paying for idle). It also reduces operational overhead.
Last updated: 2026-02-23