Remediation
Right-Size the ECS Serviceβ
- Review CPU and memory utilization, running task counts, and recent deployments in CloudWatch and Amazon ECS. Check peaks and metric coverage across a representative workload cycle. Compare utilization with latency, errors, and task health.
- Check the resource identified by the finding. For CPU, look for throttling and sustained demand. For memory, compare usage with the configured reservation and hard limit, and check for out-of-memory task stops. If both averages are high, review both resources before choosing a change.
- Increase per-task resources when individual tasks are constrained. Add replicas when the workload can distribute demand across more tasks. Review Service Auto Scaling limits and service placement events. For ECS on EC2, confirm that the cluster can place the additional or larger tasks, including during deployment.
Record the current task definition ARN, desired count, and scaling settings. 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β
Increase the Task Sizeβ
-
Prepare a task definition registration file with the required CPU or memory increase. Update container reservations or limits where needed and preserve unrelated settings. For Fargate, select a supported CPU and memory combination. Supported Fargate task sizes
-
Register the revised task definition 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 the ECS deployment controller, deploy the revision with the command below. 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}}
Increase the Replica Countβ
-
Choose a desired count that can handle representative peak demand. If Service Auto Scaling is enabled, confirm that the count fits its limits. Review the scaling maximum and placement capacity if the service has reached its limit.
-
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 tasks were placed and are healthy. Compare resource utilization, latency, errors, and task restarts with the baseline under 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.