AWS ECS Pricing & Cost Guide (EC2 vs Fargate drivers)
Use this page when you need to decide what belongs inside the ECS bill before you debate task sizing, support line items, or scaling fixes.
This guide is the ECS bill-boundary page: launch-type compute, surrounding infrastructure, and launch-type-specific storage or network lines should be modeled as separate cost surfaces rather than one generic service total.
Start here: separate the ECS bill surfaces
- Launch-type compute: EC2 instance-hours or Fargate vCPU-hours and memory GB-hours.
- Surrounding infrastructure: load balancers, logs, metrics, NAT, egress, and cross-AZ transfer.
- Launch-type-specific lines: EBS and snapshots matter on EC2-backed services; task-hour billing matters on Fargate-backed services.
1) Compute (baseline)
- EC2 launch type: instance-hours, plus EBS if you attach volumes.
- Fargate: vCPU-hours + memory GB-hours, scaled by running tasks.
- Idle matters: for EC2, paying for idle capacity is often the largest hidden multiplier.
2) Load balancers (baseline + capacity units)
- ALB/NLB hourly baseline per load balancer.
- Capacity units (LCU/NLCU) driven by connections, throughput, and rule evaluations.
- One load balancer per service can create a large baseline even when services are quiet.
3) Logs and metrics
- Log ingestion grows with request volume and verbosity.
- Retention creates a steady GB-month baseline.
- Query scans spike during incidents and heavy dashboards.
- Metrics costs grow with custom metric cardinality and polling.
4) Networking (NAT, egress, cross-AZ)
- NAT gateway: hourly + GB processed can dominate private subnet workloads.
- Internet egress: bytes leaving AWS to users/external systems.
- Cross-AZ transfer: microservice chatter and uneven placement can create internal transfer.
5) Storage (when you run on EC2)
- EBS volumes (GB-month + optional IOPS/throughput).
- Snapshots (change rate x retention).
- Stateful dependencies often dwarf the service compute line item.
6) Registry behavior (ECR)
- Storage grows with retention and CI push frequency.
- Pull traffic spikes during cluster autoscaling and cold starts.
- Cross-region pulls and NAT paths can change transfer costs materially.
Rule of thumb (sanity check)
If your service is quiet but your bill is high, look for baselines: load balancer hourly, NAT hourly, and retention (logs, snapshots, registry). If your traffic spikes, look for variable drivers: logs, transfer, and capacity units.
Once the bill boundary is clear, use ECS task sizing for measured task assumptions, ECS cost model beyond compute for missed line items, and ECS autoscaling cost pitfalls for production fixes.
Validation checklist
- Validate average (not peak) running tasks and the busy-month scenario.
- Validate log ingestion GB/day and retention settings for each service.
- Validate NAT processed GB and egress GB for the real traffic paths.
- Validate load balancer count and whether they are shared across services.
Sources
- ECS pricing: aws.amazon.com/ecs/pricing
- Fargate pricing: aws.amazon.com/fargate/pricing