Auto Scaling
Developer Guide
Did this page help you?  Yes | No |  Tell us about it...
« PreviousNext »
View the PDF for this guide.Go to the AWS Discussion Forum for this product.Go to the Kindle Store to download this guide in Kindle format.

Scheduled Scaling

Scaling based on a schedule allows you to scale your application in response to predictable load changes. For example, every week the traffic to your web application starts to increase on Wednesday, remains high on Thursday, and starts to decrease on Friday. You can plan your scaling activities based on the predictable traffic patterns of your web application.

To configure your Auto Scaling group to scale based on a schedule, you need to create scheduled actions. A scheduled action tells Auto Scaling to perform a scaling action at certain time in future. To create a scheduled scaling action, you specify the start time at which you want the scaling action to take effect, and you specify the new minimum, maximum, and desired size you want for that group at that time. At the specified time, Auto Scaling updates the group to set the new values for minimum, maximum, and desired sizes, as specified by your scaling action.

You can create scheduled actions for scaling one time only or for scaling on a recurring schedule.

Programming Considerations for Scheduled Actions

When you create a scheduled action, keep the following programming considerations in mind.

  • Auto Scaling guarantees the order of execution for scheduled actions within the same group, but not for scheduled actions across groups.

  • A scheduled action generally executes within seconds. However, the action may be delayed for up to two minutes from the scheduled start time. Because Auto Scaling executes actions within an Auto Scaling group in the order they are specified, scheduled actions with scheduled start times close to each other may take longer to execute.

  • You can create a maximum of 125 scheduled actions per month per Auto Scaling group. This allows scaling four times a day for a 31-day month for each Auto Scaling group.

  • A scheduled action must have a unique time value. If you attempt to schedule an activity at a time when another existing activity is already scheduled, the call is rejected with an error message noting the conflict.

Scheduling Scaling Using the AWS CLI

Complete the following tasks to create a scheduled action to scale your Auto Scaling group.

Create a Launch Configuration

Use the following create-launch-configuration command to create a launch configuration named my-lc:

aws autoscaling create-launch-configuration --launch-configuration-name my-lc --image-id ami-514ac838 --instance-type m1.small --associate-public-ip-address

Create an Auto Scaling Group

Use the following create-auto-scaling-group command to create an Auto Scaling group named my-asg.

aws autoscaling create-auto-scaling-group --auto-scaling-group-name my-asg --launch-configuration-name my-lc --max-size 5 --min-size 1 --availability-zones "us-west-2c"

Create a Schedule for Scaling Actions

You can create a schedule for scaling one time only or for scaling on a recurring schedule.

To schedule scaling for one time only

To increase the number of running instances in your Auto Scaling group at a specific time, use the following put-scheduled-update-group-action command to create a scheduled action named ScaleUp that runs at the specified time (specified in "YYYY-MM-DDThh:mm:ssZ" format in UTC time):

aws autoscaling put-scheduled-update-group-action --scheduled-action-name ScaleUp --auto-scaling-group-name my-asg --start-time "2013-05-12T08:00:00Z" --desired-capacity 3 

To decrease the number of running instances in your Auto Scaling group at a specific time, use the following as-put-scheduled-update-group-action command to create a scheduled action named ScaleDown that runs at the specified time (specified in "YYYY-MM-DDThh:mm:ssZ" format in UTC time):

aws autoscaling put-scheduled-update-group-action --scheduled-action-name ScaleDown --auto-scaling-group-name my-asg --start-time "2013-05-13T08:00:00Z" --desired-capacity 1 

To schedule scaling on a recurring schedule

You can specify a recurrence schedule using the Unix cron syntax format. For more information about cron syntax, see the Cron Wikipedia entry.

Use the following put-scheduled-update-group-action command to create a scheduled action named scaleup-schedule-year that runs at 00:30 hours on the first of January, June, and December each year:

aws autoscaling put-scheduled-update-group-action --scheduled-action-name scaleup-schedule-year --auto-scaling-group-name my-asg --recurrence "30 0 1 1,6,12 0" --desired-capacity 3