ECS Fargate vs ECS EC2
Same ECS orchestrator. Two ways to run your containers.
Fargate — you pay per task. AWS runs the servers. EC2 — you pay per instance, cheaper per-vCPU, but you manage everything. The break-even math is honest — and fragile.
- ✓ Zero tolerance for infrastructure management
- ✓ Dev/staging — stop to $0 at night
- ✓ Bursty workloads — instant scale from pool
- ✓ Under 10 services (1 EC2 instance minimum = inefficient)
- ✓ No ops team — no AMI, no ASG, no patching
- ✓ Predictable, steady workloads — right-size once
- ✓ 10+ services — bin-packing efficiency improves with volume
- ✓ Cost-sensitive at scale — per-vCPU savings compound
- ✓ GPU or specific instance types — Fargate doesn't do GPU
- ✓ Want deep Savings Plans — EC2 3-year RI up to 72% off
Table of contents
Same service, two compute paths
The same ECS service, same task definition, same ALB. The difference is invisible to your application — and visible on your AWS bill.
Pricing — where the serverless premium lives
Fargate's premium isn't in the vCPU rate — it's in memory pricing. EC2 includes memory in the instance price. Fargate charges separately per GB at $0.00444/GB-hr. For memory-heavy workloads, this is where costs diverge.
Example: m7g.xlarge = $0.1632/hr for 4 vCPU + 16 GB (memory included). Fargate equivalent = 4 × $0.04048 + 16 × $0.00444 = $0.1619 + $0.0710 = $0.2329/hr — 43% more. The gap is entirely the memory charge.
Key insight:At small scale, EC2's instance granularity is the cost driver — the 1-instance minimum plus HA across 2 AZs doubles the bill for a handful of services. Fargate spreads tasks across AZs at per-task cost, making HA free. At large scale (20+ services with 5+ ideal instances), bin-packing slack (~15-25%) is the real overhead — and EC2's per-vCPU advantage wins out. The crossover point depends on your workload shape.
How the comparison math works — HA-equivalent Fargate vs EC2 cost model
Cost calculator
interactiveSame ECS task definitions on Fargate vs EC2. Fargate price already includes AZ-spread HA — this is an HA-equivalent comparison.
Spot pricing — set and forget vs active management
Both launch types support Spot. The difference is operational complexity.
- — ~70% off, flat — not hourly-bid. Prices adjust on long-term trends
- — No instance selection, no AZ diversification. Flip to Spot and forget
- — 2-min termination notice. Best for dev, staging, CI/CD — any fault-tolerant workload
- — 55-65% avg (us-east-1, 7-day CLI scan, Jun 2026). Up to 90% advertised
- — Must diversify across 3+ types + 2+ AZs. Common: 80% Spot + 20% On-Demand
- — Instance type selection, ASG configuration, Spot interruption handling — all manual
describe-spot-price-history (us-east-1, 7-day window, Jun 2026)Don't choose — run both
ECS capacity providers let you mix Fargate and EC2 in the same cluster and the same service. Use EC2 for predictable production base with Savings Plans. Use Fargate for burst capacity and dev environments that stop to $0.
Full comparison — 12 dimensions
Sources and methodology
- AWS Fargate pricing — vCPU $0.04048/hr, GB $0.00444/hr, Spot ~70% off
- AWS EC2 On-Demand pricing — m7g instance family
- ECS capacity provider docs
- Datadog Container Report 2023 — 65%+ containers overprovisioned (2.4B containers analysed)
- instances.vantage.sh — EC2 Spot price cross-reference
- EC2 Spot prices: AWS CLI
describe-spot-price-history(us-east-1, 7-day window, Jun 2026) - Bin-packing slack: 15–25% band (midpoint 20%) — AZ fragmentation + EC2 instance sizing slack. Separate from Datadog's container-level 65% overprovisioning finding, which applies to both ECS and EKS.
- FTE estimates: directional — actual depends on team expertise, automation maturity, and compliance requirements
- — Dev/staging — stop to $0, no lingering instances
- — Bursty workloads — instant scale from shared pool
- — Small fleets — under 10 services, EC2 min inefficient
- — Zero ops — no AMI, no ASG, no patching
- — Cost control at scale — per-vCPU savings compound
- — GPU or specific instance types — Fargate can't run GPU
- — Deep Savings Plans — 3-year EC2 RI up to 72% off
- — Predictable, steady production loads
Most teams run both. EC2 for steady production base with Savings Plans. Fargate for dev/staging that stops to $0. If you already run a mixed Fargate/EC2 fleet, the audit shows per-environment real costs and where instances sit idle.
Fleet Audit — free, read-only, 15 minutes. Runs locally in your browser. Shows every environment with real costs.
Run Fleet Audit →