3
votes

Is there a effective way how to set-up rule in AWS auto-scaling group to terminate instances which are under given % of CPU ?

We are using autoscaling for bunch of EC2 instances - quite intensive computations over the night so CPUs are burning or doing nothing (if incoming task queue is empty).

Monitoring rules allows you to monitor average CPU (for whole group) but we have quite often few instances which are finished and there's nothing much to do (if incoming task queue is empty).

Example :

  • Rule #1 : scale down if average CPU < 50%
  • Rule #2 : scale up if average CPU > 80%

  • 15 instances running in total :

    • 12 instances fully loaded CPU average +- 70%
    • 3 instances idle : CPU average +- 10 %

Average CPU for whole group : 58 % - this will not trigger 'scale down' rule, is there a way how to optimize rules within auto-scaling group to deal with this problem ?

Thank you

2

2 Answers

2
votes

You could use the minimum CPU usage of the Auto-Scaling Group, rather than the average. Scale down if the minimum CPU usage of the group is less than (say) 10% This will terminate the 3 idling instances in your example, leaving the other 12 fully loaded instances alone.

Minimum CPU Alarm

0
votes

You can setup a cron job which will periodically check the individual CPU usage of the ec2 instances and terminate those instances which are below a certain threshold.