3

I have setup EC2 Autoscale policies along CPU monitors and it's working well.

I have occasional bursts that triggers autoscale and more servers are added.

If the servers are experiencing a burst that endures 30 minutes and two more instances are added to help with the current jobs I'd like to keep them around for 59 minutes (since I paid for 1 hour) instead of them being terminated when scaling down is triggered.

So basically I want to move the checks around the one hour mark from start and see if they are still needed, otherwise shut down. Should I play with cooldown or grace-period?

Here are the current rules (alarms not shown), as you can see I'm using the new OldestInstance termination policy.

as-create-auto-scaling-group MyASGroup \
--availability-zones us-east-1c \
--launch-configuration MyLaunchConfig \
--grace-period 300 \
--health-check-type ELB \
--min-size 1 \
--max-size 3 \
--desired-capacity 1 \
--load-balancers MyELB \
--termination-policies "OldestInstance" \
--tag ...

as-put-scaling-policy ScaleUp \
--type ChangeInCapacity \
--auto-scaling-group MyASGroup \
--adjustment=1 \
--cooldown 300

as-put-scaling-policy ScaleDown \
--type ChangeInCapacity \
--auto-scaling-group MyASGroup \
--adjustment=-1 \
--cooldown 300

Is such thing possible? Thanks.

Claudio Poli
  • 285
  • 3
  • 10

2 Answers2

3

You should adjust your cooldown period for the ScaleDown policy to keep your instances up for longer. Grace-period should be set to the amount of time it takes to spin-up your instance, so no need to adjust it (if your instances are up in less than 300 seconds). Once you have your policies in place, you can test them by using the as-execute-policy command with the --honor-cooldown parameter. This will allow you to make sure that cooldown works they way you want, without having to wait for the load conditions to be met.

Edwin
  • 1,041
  • 7
  • 17
  • Thanks, I changed the cooldown of the scale down policy. Do you know what purpose servers the cooldown on the scale up? – Claudio Poli Feb 04 '13 at 14:31
  • I would use it if I wanted to be very responsive to scale up (like CPU greater than 60 percent for one minute), but wanted to limit the rate that my instances scaled up (want to wait 30 minutes for the second scale up. – Edwin Feb 04 '13 at 19:05
0

Another solution you might consider is to change the Default Termination Policy of your ASG to "Nearest Instance Hour." This still leaves some up to chance, but it gives you ALL the instances in your ASG to choose from, not just the ones most recently spun up, and depending on how it works out, it may save you money compared to just leaving the instances on for longer, because there's no guarantee that the ASG will terminate those new instances specifically when it's time to scale in. In fact, in the time the ASG was at expanded capacity, some of the original instances may have finished another instance hour.