awsecsfargatecost-optimization

ECS capacity providers cost: mixing Spot, on-demand, and scaling

ECS capacity providers decide where your tasks run and in what mix, and that decision drives the cost of an ECS cluster. Splitting between on-demand and Spot, tuning target capacity, and choosing Fargate versus EC2 providers can cut container spend substantially. Here is how they work on cost.

The C3X Team··7 min read

Quick answer

ECS capacity providers control where tasks are placed and in what proportion, which directly shapes cluster cost. For Fargate, the two built-in providers are FARGATE (on-demand) and FARGATE_SPOT (up to about 70 percent cheaper, interruptible), and a capacity provider strategy sets a base and weight to blend them, for example a small on-demand base for stability plus a Spot-weighted remainder for savings. For EC2-backed ECS, capacity providers tie to Auto Scaling groups and manage instance scaling with a target capacity setting that controls how full instances run before scaling out. Tuning the base, weight, and target capacity is what turns capacity providers into savings: a stable on-demand floor with a Spot-heavy elastic top is the cheapest safe mix.

In ECS, capacity providers are the mechanism that decides where tasks land and how the underlying capacity scales. They are also one of the most direct cost levers you have, because the mix of on-demand and Spot, and how tightly instances are packed, follows directly from how you configure them. Left at defaults, they leave savings on the table; tuned, they cut a cluster's bill significantly.

The two Fargate providers

ProviderCostInterruptionRole in strategy
FARGATEOn-demand rateNoneStable base
FARGATE_SPOTUp to ~70% cheaper2-minute warningElastic, savings-heavy top

A capacity provider strategy assigns each provider a base (a minimum number of tasks) and a weight (the relative share of tasks beyond the base). A common cost-optimized strategy sets a small base on FARGATE so the service always has some stable capacity, then weights the rest heavily toward FARGATE_SPOT so most scaling happens on cheap, interruptible capacity. If Spot is reclaimed, the on-demand base keeps serving while replacements reschedule, the pattern from the Fargate Spot guide.

Base and weight, worked through

Say a service runs 10 tasks. A strategy of base 2 on FARGATE and weight 1 FARGATE / weight 4 FARGATE_SPOT puts the first 2 tasks on on-demand and splits the remaining 8 roughly 1-to-4, so about 6 or 7 run on Spot. If regular Fargate costs about $36 per task-month and Spot about $11, moving 6 tasks from on-demand to Spot saves roughly $150 a month on that one service, while the on-demand base preserves stability. The base and weight are the dials that set the savings-versus-stability balance.

EC2-backed capacity providers

For ECS on EC2, capacity providers tie to Auto Scaling groups and add managed instance scaling driven by a target capacity setting, the percentage of instance capacity you want utilized before scaling out. A target capacity of 100 packs instances full before adding more (cheapest, least headroom); a lower target leaves buffer for bursts (more headroom, more cost). Tuning target capacity controls how efficiently tasks are bin-packed onto instances, which is the EC2-side equivalent of right-sizing, and those instances can themselves run on Spot for further savings.

Fargate providers or EC2 providers

The choice of provider type is itself a cost decision. Fargate providers (FARGATE and FARGATE_SPOT) charge per task with no cluster to manage, simplest and often cheapest at small to moderate scale. EC2 providers require running and bin-packing instances but can be cheaper at high, steady scale where you can pack tasks densely and commit the instances to Savings Plans, the tradeoff in the Fargate versus EC2 comparison. Capacity providers are how you express whichever choice you make.

Tuning for cost

Set a small on-demand base for stability and weight the rest toward Spot, tune EC2 target capacity high enough to pack instances densely without starving bursts, and prefer Fargate providers for simplicity or EC2 providers for dense, committed scale. Reassess as traffic grows. Price your capacity provider strategy, the on-demand base plus the Spot-weighted top, against the resource catalog so the cluster's blended cost is clear before you deploy.

FAQ

What are ECS capacity providers?

Capacity providers control where ECS tasks are placed and how the underlying capacity scales. For Fargate, the two built-in providers are FARGATE (on-demand) and FARGATE_SPOT (up to about 70 percent cheaper, interruptible). For EC2-backed ECS, capacity providers tie to Auto Scaling groups and manage instance scaling. A capacity provider strategy sets a base and weight for each provider, which directly determines the cluster's cost.

How do I use capacity providers to save money?

Set a small base of tasks on the on-demand FARGATE provider for stability, then weight the remaining tasks heavily toward FARGATE_SPOT so most scaling happens on cheap, interruptible capacity at up to 70 percent off. If Spot is reclaimed, the on-demand base keeps serving while replacements reschedule. For a 10-task service, moving 6 or 7 tasks to Spot can save roughly $150 a month while preserving a stable floor.

What is target capacity in an ECS capacity provider?

For EC2-backed capacity providers, target capacity is the percentage of instance capacity you want utilized before ECS scales out the Auto Scaling group. A target of 100 packs instances full before adding more, which is cheapest but leaves no headroom; a lower target leaves buffer for bursts at more cost. Tuning target capacity controls how densely tasks are bin-packed onto instances, the EC2-side equivalent of right-sizing.

Should I use Fargate or EC2 capacity providers?

Fargate providers (FARGATE and FARGATE_SPOT) charge per task with no cluster to manage, making them simplest and often cheapest at small to moderate scale. EC2 providers require running and bin-packing instances but can be cheaper at high, steady scale where you can pack tasks densely and commit the instances to Savings Plans. Choose based on scale and whether you can keep EC2 instances densely and efficiently utilized.

How does C3X help with ECS capacity provider cost?

C3X prices your ECS configuration from Terraform against a live catalog, so the cost of a capacity provider strategy, the on-demand base, the Spot-weighted top, and the underlying instances, is visible before you deploy. That helps you tune the base, weight, and target capacity for the cheapest safe mix, and compare Fargate against EC2 providers as concrete monthly numbers in the pull request.

What to do next

Tune your ECS capacity mix for the cheapest safe cluster. C3X reads your Terraform and prices your resources against a live catalog. Start with the quickstart.

Try C3X on your own Terraform

Free and open source. No API key required. One command to install, one command to estimate.