Remediation
Right-Size the ECS Serviceβ
Review CPU and memory utilization, running task counts, and recent deployments in CloudWatch and Amazon ECS. Check peak demand, metric coverage, and latency over a representative workload cycle. Choose smaller tasks when individual tasks have headroom, or fewer replicas when the service can meet its availability and throughput requirements with a lower task count.
Record the current task definition ARN, desired count, and Service Auto Scaling settings before making changes. Test the proposed capacity under representative load. For services managed through infrastructure as code, apply the change through the existing deployment process.
Using the AWS CLIβ
Reduce the Task Sizeβ
-
Prepare a task definition registration file with the lower CPU or memory allocation. Preserve unrelated settings and confirm that container reservations and limits fit the new task size. For Fargate, choose a supported CPU and memory combination. Supported Fargate task sizes
-
Register the new revision and record the returned ARN.
aws ecs register-task-definition \
--region {{region}} \
--cli-input-json file://{{task-definition-file}} \
--query 'taskDefinition.taskDefinitionArn' \
--output text -
For a service using the ECS deployment controller, deploy the new revision with the following command. For CODE_DEPLOY, create a CodeDeploy deployment. For EXTERNAL, create and promote an updated task set through the external controller. UpdateService deployment controller requirements
aws ecs update-service \
--region {{region}} \
--cluster {{cluster-name}} \
--service {{service-name}} \
--task-definition {{new-task-definition-arn}}
Reduce the Replica Countβ
-
Choose a desired count that leaves enough replicas for peak demand, deployments, and failover. If Service Auto Scaling is enabled, review its minimum capacity and scale-out settings with the proposed count.
-
Update the desired count.
aws ecs update-service \
--region {{region}} \
--cluster {{cluster-name}} \
--service {{service-name}} \
--desired-count {{desired-count}}
Verify the Changeβ
- Confirm that the deployment is healthy and tasks are running as expected. Check CPU and memory utilization, latency, and task restarts during representative demand.
- If performance or availability regresses, redeploy the previous task definition through the service's deployment controller or restore the previous desired count and scaling settings, depending on what changed.
- Estimate Fargate savings from the revised vCPU and memory allocations and expected task-hours. For ECS on EC2, estimate compute savings from the backing capacity that can be removed.