Skip to main content

Remediation

Reduce Excess ECS Task Reservations​

  1. In CloudWatch, compare CPU reservation with CPU utilization or memory reservation with memory utilization over the same periods. Confirm the gap across a representative workload cycle and check peak demand, CPU throttling, and memory-related task stops.
  2. Review the running EC2-backed tasks and the task definitions that drive their reservations. For memory, check container soft reservations and hard limits. Include sidecars, task placement constraints, and deployment headroom when deciding what to reduce. Amazon ECS cluster reservation metrics
  3. Record the current task definition ARN and test the proposed change under representative load. Preserve the CPU or memory allocations needed at peak demand. For workloads managed through infrastructure as code, apply the change through the existing deployment process.

Using the AWS CLI​

  1. Prepare a task definition registration file with the lower allocation for the resource identified by the finding. Preserve unrelated settings and confirm that the revised task allocation accommodates its containers.

  2. 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
  3. For a service using the ECS deployment controller, deploy the new 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. For scheduled or standalone tasks, update the configuration that launches the workload. UpdateService deployment controller requirements

    aws ecs update-service \
    --region {{region}} \
    --cluster {{cluster-name}} \
    --service {{service-name}} \
    --task-definition {{new-task-definition-arn}}

Verify the Change​

  1. Confirm that tasks using the revised definition can be placed and remain healthy. Check reservation, utilization, throttling, task restarts, and application performance under representative demand.
  2. Restore the previous task definition revision through the same deployment or launch process if placement or performance regresses.
  3. Estimate EC2 savings once the freed reservation allows the backing fleet to shrink.