- Newest
- Most votes
- Most comments
There are several potential reasons why your ECS service auto scaling is not scaling in despite the alarm being in the "In Alarm" state:
-
Safety mechanism: Application Auto Scaling has a built-in safety feature that prevents scale-in actions if it calculates that removing a task would immediately cause the metric to exceed the target value again. With a small service (min: 1, max: 2), removing one task might push the memory utilization back over the 85% threshold, causing the system to avoid scaling in.
-
Cooldown periods: Your scale-in cooldown period is set to 180 seconds. Make sure enough time has passed since the last scaling activity before expecting a scale-in action.
-
Metric calculation: The system might be determining that the current load, even though below the threshold, doesn't warrant removing a task based on its internal calculations of how that would affect the remaining infrastructure.
To troubleshoot and potentially resolve this issue:
-
Check scaling activities: Use the AWS CLI to check why scale-in didn't happen by reviewing the scaling activities, including activities that didn't result in scaling.
-
Consider alternative scaling approaches: If target tracking isn't working as expected, you might need to:
- Use step scaling instead (though this may result in a less stable environment)
- Change the target tracking metric to one that better represents when scale-in is safe
- Add another policy tracking a different metric while disabling scale-in on the memory policy
-
Review your binpack strategy: Your deployment strategy using binpack for CPU and memory might be affecting how tasks are distributed, potentially making it harder for the system to determine when scale-in is appropriate.
-
Adjust target capacity: Your cluster auto scaling target capacity is set to 80%, which might interact with your service scaling decisions. You might need to adjust this value to better align with your service scaling needs.
Sources
AWS ECS EC2-backed auto scaling scale-in is not working | AWS re:Post
Optimize Amazon ECS service auto scaling - Amazon Elastic Container Service
Automatically manage Amazon ECS capacity with cluster auto scaling - Amazon Elastic Container Service
You mentioned - "However, scale-in does not occur, even when the memory usage drops below the target and alarm status is IN alarm all the datapoints are satisfied". However, if the status is IN ALARM, it will not scale in as it still in alarm.
Do you have the CPU/ memory metrics for the EC2 or only the ECS. It's possible the cpu/memory is still high even though the ECS has cooled down. Also, the scale in will take effect after the time specified.
Relevant content
- asked a year ago
- AWS OFFICIALUpdated a year ago
