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.
3 svc × 0.5 vCPU + 1 GB, 24/7
$54/movs$60–119/mo
1 m7g.large ($60). HA across 2 AZs = 2 instances ($119). Fargate's price already spreads tasks across AZs.
Same orchestrator, different compute. Task definitions, service definitions, IAM roles, ALB configuration — identical. The difference is purely in how AWS runs your containers and how you pay. ECS capacity providers let you run both simultaneously — 80% EC2 for base, 20% Fargate for burst. Migrating is a strategy change, not a rewrite.
Choose Fargate
✓ 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
Choose EC2
✓ 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
Same ECS task definition, same ALB, same IAM role. Fargate: AWS finds capacity in shared pool → tasks start. EC2: you provision instances in ASG → ECS places tasks on them. The difference is invisible to your app — visible on your bill.
The same ECS service, same task definition, same ALB. The difference is invisible to your application — and visible on your AWS bill.
Fargate path
1.You: set desiredCount = 3
2.AWS: finds capacity in shared Fargate pool
3.3 tasks start. No instances. No AMI.
4.Your bill: 3 × (vCPU + GB) × seconds running
5.You: set desiredCount = 0 → $0 bill
EC2 path
1.You: provision m7g.xlarge × 2 in an Auto Scaling group
2.ECS agent: registers instances with your cluster
3.You: set desiredCount = 3. ECS places tasks on instances
5.You: set desiredCount = 0 → still paying for 2 instances
Pricing — where the serverless premium lives
Fargate charges memory separately ($0.00444/GB-hr). EC2 includes memory in the instance price. For 4 vCPU + 16 GB, Fargate is 43% more expensive than m7g.xlarge. The premium buys zero server management, instant scaling, and stop-to-$0.
“Fargate: $0.04048 per vCPU-hour + $0.00444 per GB-hour. EC2 m7g.xlarge: $0.1632 per hour for 4 vCPU + 16 GB — memory included. For 4 vCPU + 16 GB, Fargate costs 43% more. The gap is entirely the memory charge: $0.0710/hr.”
— aws.amazon.com/fargate/pricing + aws.amazon.com/ec2/pricing/on-demand, verified June 2026
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.
Workload / monthFargateEC2 (m7g.xlarge)
3 services · 0.5 vCPU + 1 GB · 24/7
EC2 minimum = 1 instance ($60). For production HA across 2 AZs = 2 instances ($119). Fargate's price already includes HA — tasks spread across AZs at per-task cost. Fargate wins either way.
$54/mo$60–$119/mo
8 services · 0.5 vCPU + 1 GB · 24/7
Ideal: 1 m7g.xlarge perfectly fits ($119) — EC2 wins 17%. HA-equivalent: 2 instances across AZs ($238). Fargate's per-task AZ spread undercuts EC2's whole-box redundancy. Fargate wins ~40% on HA basis.
$144/mo$119–$238/mo
20 services · 1 vCPU + 4 GB · 24/7
Ideal: 5 m7g.xlarge ($595). Realistic (15-25% bin-packing slack across AZ fragmentation): 6 instances ($714). EC2 wins 16-30% at this scale. At even larger scale the gap widens — EC2's per-vCPU advantage compounds.
$850/mo$595–$714/mo
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
Fargate cost (pay per task — AZ-spread HA included)
At small scale (ideal ≤ 1): 2 instances — 1-instance minimum + HA across 2 AZs. At large scale (ideal > 1): ceil(ideal × 1.20) — bin-packing slack (~15–25%) from AZ fragmentation + imperfect packing.
Example (8 svc): ideal = 1 m7g.xlarge → $119/mo. HA-equivalent = 2 instances → $238/mo. The HA floor doubles the bill — this is instance granularity, not waste.
Example (20 svc): ideal = 5 m7g.xlarge → $595/mo. With slack = ceil(5 × 1.20) = 6 → $714/mo. At this scale, the percentage behaves like a percentage.
Why this is an honest comparison
Fargate's quoted price already includes AZ-spread HA — tasks are distributed across availability zones at per-task cost with no premium. EC2 requires ≥2 instances for the same resilience. This model makes the comparison HA-equivalent: both priced for production deployment across AZs.
HA floor (2 AZs) — production resilience requires ≥2 instances
What Fargate hides — the 6 things you manage on EC2
AMI maintenance, ASG management, ECS agent updates, capacity planning, HA redundancy cost, OS security — all absorbed by Fargate. EC2: these are recurring calendar events. Fargate: they don't exist.
The per-vCPU savings don't come free. These are the ongoing tasks Fargate absorbs.
Important:Fargate's price already includes AZ-spread HA — tasks are distributed across availability zones automatically. EC2 requires ≥2 instances across AZs for equivalent production resilience. This instance granularity — not just bin-packing — is what makes EC2 expensive at small scale.
01AMI maintenance
ECS-optimised AMI updates ~every 2 weeks. Kernel, containerd, Docker patches — you bake new AMIs and roll them out via instance refresh. Miss one: security vulnerability on every node.
02ASG management
Scaling policies, desired/min/max, instance refresh for AMI updates, AZ balancing, lifecycle hooks for graceful drain. Gets complex when you mix Spot + On-Demand in one ASG.
03ECS agent
ECS container agent runs on each EC2 instance. You update it, troubleshoot it when 'instance not registering', and ensure it starts on boot. A stuck agent = tasks can't be placed.
04Capacity planning
'How many m7g.xlarges for 12 services at 0.5 vCPU each?' You do this math. Guess wrong: overprovision (waste) or underprovision (tasks can't place). ECS placement strategies help but can't fix bad capacity math.
05HA redundancy cost
Production needs ≥2 instances across AZs. At small scale (1 ideal instance), HA doubles your bill — you buy a whole redundant box. Fargate spreads tasks across AZs at per-task cost. At larger scale this cost amortises across more instances.
06OS security
Kernel CVEs, containerd vulns, SSH hardening, audit logs — on you. Fargate handles all of this transparently. EC2: patching is your recurring calendar event.
Fargate: ~0.05 FTE
Task definitions, services, monitoring. That's it.
FTE = Full-Time Equivalent (38-40 hrs/week of one engineer). Directional industry estimate — team expertise shifts these numbers.
Spot pricing — set and forget vs active management
Fargate Spot: ~70% off, flat, no diversification needed. EC2 Spot: 55-65% avg, must diversify 3+ types + 2 AZs. Both: 2-min termination notice. Fargate is simpler; EC2 can be cheaper with active management.
Both launch types support Spot. The difference is operational complexity.
Fargate Spot~70% off
— ~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
EC2 Spotup to 90% off
— 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
Sources:
— EC2 Spot prices from AWS CLI describe-spot-price-history (us-east-1, 7-day window, Jun 2026)
ECS capacity providers let you mix Fargate and EC2 in the same cluster. 80% EC2 for steady production base with Savings Plans. 20% Fargate for burst and dev/staging that stops to $0. Migrating is a configuration change, not a rewrite.
“ECS capacity providers let you specify a strategy: 80% EC2, 20% Fargate. ECS places tasks accordingly. No Terraform changes needed — same task definition works on both launch types.”
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.
1.Keep your existing ECS service — same task definition, same ALB, same IAM roles. Nothing changes for your application.
2.Add an EC2 capacity provider — an Auto Scaling group of instances. Set strategy: 80% EC2, 20% Fargate.
3.ECS places tasks according to strategy. New services start on Fargate. Migrate existing services one at a time by changing their capacity provider strategy.
4.No Terraform rewrite. No downtime. Migration is a configuration change, not an infrastructure project.
Every dimension: pricing model, bin-packing, scale-up speed, stop-to-$0, Spot, GPU support, Savings Plans depth, task size flexibility, and engineering time — all with source tags and verified pricing.
DimensionFargateEC2
What you pay for
AWS pricing pages (Jun 2026)
vCPU + GB per task, per second. No instances — you never see a serverEC2 instances × runtime. Pay regardless of utilisation. 1 instance minimum always
Memory cost
AWS Fargate + EC2 pricing
$0.00444/GB-hr — charged separately. 8 services × 1 GB each = $0.0355/hr just for memoryIncluded in instance price. m7g.xlarge = 16 GB at no extra charge beyond the $0.1632/hr
Instance granularity & waste
Datadog Container Report + estimate
0% — no instances. Tasks spread across AZs at per-task cost. HA is freeSmall: 2-instance HA floor (2 AZs). Large: 15-25% bin-packing slack from AZ fragmentation + imperfect packing
Stop to $0
AWS ECS docs
Yes — SetDesiredCount to 0. No lingering compute bill. ALB + data transfer remainNo. Instances bill 24/7 even with zero tasks. Terminate instances to reach $0, recreate to resume
Server management
AWS ECS docs
None. AWS provisions, patches, scales transparently. You never touch an AMIYou: AMI updates every ~2 weeks, security patches, ECS agent, ASG tuning, capacity planning
Scale-up speed
AWS ECS best practices
30-90s — tasks start against shared capacity pool. 10 tasks launch in parallel0-30s if spare capacity on running instances. 2-4 min if new instance needed (ASG launch + boot + agent registration)
Spot discount
AWS Fargate pricing + CLI spot-price-history
~70% off, flat — not hourly-bid. Flip to Spot and forget55-65% avg (us-east-1, 7-day CLI scan, Jun 2026). Up to 90% advertised. Diversify 3+ types + 2+ AZs
GPU / custom instance
AWS ECS docs
Not supported — CPU/memory only. No GPU instances in FargateYes — g5, p5, trn1, any EC2 instance type. Full Graviton / Intel / AMD catalogue
Savings Plans depth
AWS Savings Plans page
Fargate Savings Plans — up to ~50% off with 1-3 year commitEC2 Savings Plans + Reserved Instances — up to ~72% off with 3-year commit on specific instances
Task size flexibility
AWS Fargate task definition docs
Fixed combos only: 0.25vCPU:0.5-2GB, 0.5vCPU:1-4GB, 1vCPU:2-8GB, 2vCPU:4-16GB, 4vCPU:8-30GB, 8vCPU:16-60GB, 16vCPU:32-120GBAny ratio your instance supports. Mix CPU-heavy and memory-heavy tasks on the same instance type
Engineering time
Industry estimate (see methodology)
~0.05 FTE — task defs, service defs, monitoring. No infrastructure ops~0.2-0.5 FTE — Fargate tasks + AMI patching, ASG tuning, capacity planning, agent updates, OS security
Migrate between them
AWS ECS capacity provider docs
ECS capacity providers let you add EC2 to a Fargate cluster. Migration is a strategy change, not a rewriteSame path — add Fargate capacity provider to EC2 cluster. Same task defs work on both
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
The bottom line
Use Fargate for
— 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
Use EC2 for
— 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.
See what your fleet actually costs
Fleet Audit — free, read-only, 15 minutes. Runs locally in your browser. Shows every environment with real costs.