Comparison

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.

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.
8 svc × 0.5 vCPU + 1 GB, 24/7
$144/movs$119–238/mo
1 m7g.xlarge ($119) — EC2 wins 17%. HA-equivalent: 2 instances ($238) — Fargate wins 40%.
20 svc × 1 vCPU + 4 GB, 24/7
$850/movs$595–714/mo
5 m7g.xlarge ideally. With bin-packing slack (15-25%): 6 instances. EC2 wins 16-30%.
Stop dev envs (8 svc) to $0 nightly
$0 idlevs$119/mo idle
Fargate stops tasks → $0. EC2 instances keep billing even with zero tasks running.
Spot discount
~70% fixedvs55–65% variable
Fargate: set and forget. EC2: diversify 3+ types + 2 AZs for stability.
AWS Fargate pricing + CLI scan (Jun 2026)
Ops staff (FTE)
~0.05 FTEvs~0.2–0.5 FTE
EC2 adds AMI patching, ASG tuning, capacity planning, agent updates. FTE = 38-40 hrs/week.
Industry estimate
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

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
4.Your bill: 2 × m7g.xlarge × 730h — regardless of utilisation
5.You: set desiredCount = 0 → still paying for 2 instances

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.

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)
services × (vCPU × $0.04048 + GB × $0.00444) × 730h
Example: 8 svc × 0.5 vCPU + 1 GB = 8 × $0.02468/hr × 730 = $144/mo. Fargate automatically spreads tasks across AZs — the quoted price includes production HA.
EC2 cost (tasks → instances, HA-equivalent)
ideal = ceil(max(total_vCPU/inst_vCPU, total_GB/inst_GB))
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.
Sources
AWS Fargate pricing (verified Jun 2026)
AWS EC2 On-Demand pricing (verified Jun 2026)
— Bin-packing slack: 15–25% band, midpoint 20%, based on Datadog 2023 (65%+ containers overprovisioned at container level) + AZ fragmentation + EC2 instance sizing slack

Cost calculator

interactive

Same ECS task definitions on Fargate vs EC2. Fargate price already includes AZ-spread HA — this is an HA-equivalent comparison.

Fargate
$170/mo
8 svc × 0.5 vCPU + 2 GB · AZ-spread HA included
EC2
$238/mo
ideal $119 · 2 × m7g.xlarge (1-instance minimum + HA (2 AZs))
Fargate saves $68/mo · $819/year
Fargate breakdown
8 svc × 0.5 vCPU + 2 GB
= 4 vCPU + 16 GB total
Pay per vCPU/GB-second · AZ-spread HA included
$0 instance overhead
EC2 breakdown
4 vCPU ÷ 4 vCPU/inst · ceil = 1 ideal
2 instances (1-instance minimum + HA (2 AZs))
2 × m7g.xlarge × $0.1632/hr × 730h
HA floor (2 AZs) — production resilience requires ≥2 instances

What Fargate hides — the 6 things you manage on EC2

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.
EC2: ~0.2–0.5 FTE
Everything above + AMI, ASG, agent, capacity planning, bin-packing, OS security
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

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)
— Cross-verified with instances.vantage.sh

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.

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.

Full comparison — 12 dimensions

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

Sources and methodology

Official AWS pricing (verified June 2026)
Third-party data
Our own research
  • 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
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.

Run Fleet Audit →