Scheduled Scaling

with tags AWS ASG autoscaling -

AWS Autoscaling alway seems to be used as a reactive measure scaling only after an alarm has been triggered. This works for meeting unexpected load, but if you have fairly steady/regular traffic patterns you can use scheduled scaling to increase capacity ahead of time. Avoiding the need to wait for CPU/Latency spikes.

If you have fairly low traffic overnight but load increases at 3am you can increase your min/max/desired instance counts ahead of time.

aws autoscaling put-scheduled-update-group-action \
--auto-scaling-group-name "Foo" \
--scheduled-action-name "Bar" \
--recurrence "50 02 * * *" \
--min-size 10 \
--max-size 40

This sets the minimum instances to 10 at 02:50 AM every day. Usually I prefer not to set the desired as all our auto scaling groups also have on demand scaling rule set so manually setting a desired number of instances could have the unintended consequences.

The recurrence =s your bog standard cron syntax so you can replace the recurrence with 50 08 * * 1-5 to set the min instances at 8:50 AM Monday to Friday or whichever pattern you desire

Notes

The only gotcha I’ve discovered so far is that if you have two conflicting scheduled actions AWS will randomly which one gets set.

ie:

0 0 * * * sets min instances to 5
0 0 25 12 * sets min instances to 15

Last time I contacted AWS Support about this issue their recommendation was to offset the more specific rule by 1min

0 0 * * * sets min instances to 5
1 0 25 12 * sets min instances to 15
obviously this only works for min instances as max and desired would immediately drop the instance count and then ramp back up

Also there is still no way to set scheduled scaling rules via the AWS web console so you’ll have to resort to the cli/api tools or use another front end such as Netflix’s Asgard

Written by
Later article
SSL and Transmission
Older article
Boxen