- Newest
- Most votes
- Most comments
To keep it simple I suggest you use Target tracking scaling policy for the ECSServiceAverageMemoryUtilization metric and tick the Turn off scale-in checkbox. So you rely only on CPU utilization as a criteria for scaling in.
This is the exact situation where you should use Target Tracking.
Create 2 Target Tracking policies, one for CPU, and one for Memory.
When there are multiple target tracking policies, any policy being above the threshold can trigger scale-out; but scale-in only happens when all policies want to scale-in at the same time. This prevents the oscillation you're describing, since scale-in only happens when both Memory and CPU are low at the same time
Hello,
The Issue: Your ECS service has two conflicting auto scaling policies:
- CPU Scaling Policy (Scale Out): Adds a task when CPU utilization exceeds 50%.
- Memory Scaling Policy (Scale In): Removes a task when memory utilization falls below 30%.
These policies can lead to unnecessary scaling activity, where a task added due to high CPU might be immediately removed due to low memory.
Here are two approaches to address this:
Prioritize Scaling Policies:
Define a priority order for the policies. The policy with higher priority will take precedence. In this case, set CPU scaling to a higher priority than memory scaling. This ensures scaling based on CPU first, and memory scaling won't remove a task immediately after CPU scaling adds one.
Steps:
- Go to the ECS service in the AWS Management Console.
- Navigate to the "Auto Scaling" section.
- Click on the "Edit" button for each policy.
- Set a higher priority value (lower number) for the CPU scaling policy.
Combine Scaling Metrics:
Create a single policy that considers both CPU and memory utilization. This policy can add or remove tasks based on a combined threshold that factors in both metrics.
Steps:
- Go to the ECS service in the AWS Management Console.
- Navigate to the "Auto Scaling" section.
- Click on "Create a new policy."
- Choose "Target Tracking Scaling" policy type.
- Define a target for combined CPU and memory utilization (e.g., average CPU above 40% and memory above 40%).
- Set scaling actions (add/remove tasks) based on deviations from the target.
ECS Auto Scaling doc: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service-auto-scaling.html.
very thankyou for imediate response.
i appriciate your answer but i not find anything like Prioritize Scaling Policies in ECS service auto scaling.
and also target tracking scaling policy not support to select multiple metrics and also no selection for any exsisting alarm.
again thank you for your response please let me know any other option to solve my issue
Relevant content
- asked 10 months ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 7 months ago
- AWS OFFICIALUpdated 2 months ago

There's no need to disable scale-in on the 2nd policy. Target tracking will only scale in when BOTH policies want to scale-in at the same time. So leaving it enabled on both will prevent oscillation