Saraswathi Apavoo
Saraswathi Apavoo

Reputation: 371

Why can't my extra autoscale EC2 instances be terminated?

One of these was to load test multiple requests and, as expected, auto scaling kicked in creating multiple instances. However, despite the fact the request count is now running extremely low I find I cannot permenantly terminate the extra instances, as they keep being recreated.

The extra instances appeared in the load balancer and I could remove them from the load balancer but, again, only temporarily.

Upvotes: 2

Views: 496

Answers (2)

bwight
bwight

Reputation: 3310

That should happen automatically actually. It seems to me that you created a policy on the auto scaling group to scale up your instances and did not create one that scales down. If you don't want to run the as-update-auto-scaling-group command each time that your cluster scales up and down.

as-put-scaling-policy MyScaleUpPolicy --auto-scaling-group MyAutoScalingGroupName--adjustment=2 --type ChangeInCapacity --cooldown 600
as-put-scaling-policy MyScaleDownPolicy --auto-scaling-group MyAutoScalingGroupName--adjustment=-2 --type ChangeInCapacity --cooldown 600

Each of those commands will return an ARN resource name. You can then create a cloud watch metric that will execute the scale up and scale down policies. Lets call them "ARN:MyScaleUpPolicy" and "ARN:MyScaleDownPolicy" in the two commands below just replace that text with the value that was returned form the as-put-scaling-policy commands.

mon-put-metric-alarm MyHighCPUAlarm --comparison-operator GreaterThanThreshold --evaluation-periods 2 --metric-name CPUUtilization --namespace "AWS/EC2" --period 120 --statistic Average --threshold 50 --alarm-actions ARN:MyScaleUpPolicy --dimensions 'AutoScalingGroupName=MyAutoScalingGroupName'
mon-put-metric-alarm MyLowCPUAlarm --comparison-operator LessThanThreshold --evaluation-periods 2 --metric-name CPUUtilization --namespace "AWS/EC2" --period 120 --statistic Average --threshold 20 --alarm-actions ARN:MyScaleDownPolicy --dimensions 'AutoScalingGroupName=MyAutoScalingGroupName'

Upvotes: 0

d3bug3r
d3bug3r

Reputation: 2586

You can fix this issue by setting your Auto Scaling desired capacity back to 1 (right now it's at 3 which is why killing the instances just results in Auto Scaling bringing up two more).

To do this you will need to download the Auto Scaling CLI (http://aws.amazon.com/developertools/2535) (or just PM me and I can do it for you) and use the API call to set the desired capacity.

hope this answers help you!!

Upvotes: 2

Related Questions