Free — no signup required

Fargate Pricing: The Math That Matters

3 min read

The Billing Dimensions

Fargate pricing has four components, billed per second with a one-minute minimum:

Dimension Approximate Price (us-east-1) Notes
vCPU ~$0.04048 / vCPU-hour Charged from task start to stop
Memory ~$0.004445 / GB-hour Charged from task start to stop
Ephemeral Storage ~$0.000111 / GB-hour First 20 GB free per task
Windows License Additional fee Only for Windows Server containers

Prices vary by region and change over time. Always verify current pricing in the AWS Fargate pricing page.

Example calculation for a 2 vCPU / 4 GB task running 8 hours:

vCPU cost:   2 × $0.04048 × 8 = $0.648
Memory cost: 4 × $0.004445 × 8 = $0.142
Total:       $0.790 for 8 hours of one task

Fargate Spot: The 70% Discount

Fargate Spot works identically to EC2 Spot Instances: AWS runs your tasks on spare capacity in their data centers at a steep discount (up to 70% off standard Fargate prices). The trade-off is that AWS can reclaim this capacity at any time with a 2-minute warning.

The warning arrives as a SIGTERM signal to your container, followed by a SIGKILL after 120 seconds. Your application must handle SIGTERM gracefully — finish in-flight requests, flush buffers, close database connections — and exit cleanly within the 2-minute window.

When Fargate Spot is appropriate:
- Stateless web servers behind an ALB (if one task dies, the ALB routes to others)
- Batch jobs that checkpoint progress and can resume from the last checkpoint
- CI/CD build runners where a failed build simply retries
- Data processing pipelines with idempotent steps

When Fargate Spot is NOT appropriate:
- Long-running stateful processes that cannot be interrupted (e.g., a 4-hour database migration)
- Tasks that hold distributed locks (interruption causes lock leaks)
- Real-time systems where a 2-minute gap in capacity is unacceptable

The Bin Packing Problem: When EC2 Wins

Fargate charges you for exactly the CPU and memory you request. EC2 charges you for the instance, regardless of how much of it you use. This creates a crossover point:

Fargate wins when your workload is variable or spiky. You pay only for active task-seconds. Idle time costs nothing.

EC2 wins when your workload is constant and you can efficiently pack multiple containers onto each instance. A c5.4xlarge (16 vCPU, 32 GB RAM) running 8 containers at $0.68/hour is significantly cheaper than 8 separate Fargate tasks consuming the equivalent resources.

The break-even point depends on your utilization rate. As a rough heuristic: if your average utilization is above 70% of provisioned capacity and it's consistent, EC2 is likely cheaper. Below 70% or with high variability, Fargate is likely cheaper or comparable when you factor in the operational cost of managing EC2 nodes.

This is one of 18 chapters

Get every chapter — Kubernetes, Terraform, SRE, distributed systems, and more — with fast daily review built in.

See pricing