Why it matters
Non-production services often run all day on full-price capacity, even though a restarted task costs nothing but a short wait.How nOps finds it
nOps reads the last 20 days of ECS Fargate billing (x86 Linux vCPU and memory) and groups it by ECS service, or by cluster for tasks without a service. A service is flagged when at least 90% of its on-demand cost in the last 7 days is non-production, judged by its environment tag, the environment nOps assigns, or words such as dev, test, qa, staging, sandbox or uat in the service or cluster name. The saving is that on-demand cost, scaled to a month, times your own Fargate Spot discount in the region, measured from at least 24 Spot hours you ran there in the last 20 days. Services are left out when you run no Fargate Spot in the region, when commitments cover most of their usage, when they already run mostly on Spot, or when the saving is under $10 a month.Before you start
The tasks must be stateless or able to restart cleanly. Permission to update the cluster and service (ecs:PutClusterCapacityProviders, ecs:UpdateService).
How to implement
- Confirm the service is not production and that its tasks can be stopped and restarted at any time.
- Make sure the cluster has the FARGATE_SPOT capacity provider (ECS console: Clusters → your cluster → Infrastructure, or
aws ecs put-cluster-capacity-providers --capacity-providers FARGATE FARGATE_SPOT). - Update the service to use a capacity provider strategy with FARGATE_SPOT (for example
aws ecs update-service --cluster CLUSTER --service SERVICE --capacity-provider-strategy capacityProvider=FARGATE_SPOT,weight=1 --force-new-deployment). Keep a small FARGATE base if you need one task that is never interrupted. - Watch the service for a few days for interrupted tasks and slow restarts.
- Update the capacity provider strategy in Terraform, CloudFormation or CDK so a later deployment does not switch it back.
Risks and considerations
- Spot tasks can be stopped with a two-minute warning. Handle SIGTERM and keep tasks stateless.
- Fargate Spot runs x86 Linux tasks only. If you move the service to Graviton instead, take that saving, not both.
- When Spot capacity is short, tasks may wait to be placed.
- To roll back, change the capacity provider strategy back to FARGATE and redeploy.
FAQs
Why doesn't nOps show this for every non-production service?
Why doesn't nOps show this for every non-production service?
nOps prices the saving at the Fargate Spot discount you already get in that region. If you run no Fargate Spot there yet, it has no measured discount to use, so it does not estimate one.
How does nOps decide a service is non-production?
How does nOps decide a service is non-production?
From its environment tag first, then the environment nOps assigns to the account or resource, then words in the service or cluster name such as dev, test or staging.