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.
Use this comparison to test utilization and operating-model fit first, then validate load balancers, logs, NAT, and storage separately before you declare EC2 or Fargate the cheaper platform.
Sources
- ECS pricing: aws.amazon.com/ecs/pricing
- Fargate pricing: aws.amazon.com/fargate/pricing