How can I use Amazon EC2 Auto Scaling scheduled actions to proactively spin up capacity for specific events and troubleshoot them?
5 minute read
How can I use Amazon Elastic Compute Cloud (Amazon EC2) Auto Scaling scheduled actions to proactively spin up capacity for specific events and troubleshoot them?
You can use scheduled actions to scale capacity according to traffic patterns or expected future traffic. For example, you might have an application that experiences increased traffic for the same two-hour time period every day. Or, you might be planning for an upcoming, one-time event where you expect traffic to significantly spike over the course of a few minutes. Scheduled actions are run at the time that you specify (in UTC). Scaling occurs based on the values that you set for the minimum, maximum, and desired capacity.
Create a scheduled action for an Auto Scaling group
Select the Auto Scaling group where you'll configure your scheduled actions.
On the Automatic scaling tab, under Scheduled actions, choose Create scheduled action.
Specify a Name for your scheduled action.
Specify the size of your Auto Scaling group, based on your use case. You must specify at least one of the following parameters:
For Min, specify the minimum number of instances required in the group.
For Max, specify the maximum number of instances that can exist in the group. Note: Setting the Min and Max parameters is helpful when you have scaling policies in addition to scheduled actions. The number of instances must be within the Min/Max range, even if a scaling policy (either scale out or scale in) is triggered after the scheduled action triggers.
For Desired, specify the number of instances required for the event.
Specify the schedule for triggering your scheduled action, based on your use case. For a one-time event: Choose Once for Recurrence. For Start time, specify the timestamp (date and time) for your event. For a recurring event: Select the recurrence interval (such as 5 minutes or 1 day). For Start time, specify the timestamp (date and time) for the first run of the scheduled action. If you specify Recurrence and Start time, the service performs the action at the start time, and then performs the action based on the specified recurrence. (Optional) Specify an End time to set an end date for the recurring scheduled action. Note: If the required recurrence interval option is not available, choose cron for Recurrence. Then, write a custom cron expression for the required schedule using the Unix cron syntax format.
Troubleshoot issues with your scheduled action
If the scheduled action wasn't triggered as expected:
Check the Auto Scaling group's activity history for the time period when the scheduled action was expected to trigger. If there's no related activity, review your scheduled action's configuration. Confirm that the recurrence pattern and start time are configured as intended.
For recurring actions: If you specified an end time, the scheduled action is automatically removed after the end time has passed. To confirm if an end time was specified, check the AWS CloudTrail API logs for the time when the scheduled action was configured. Check for the PutScheduledUpdateGroupAction API call in CloudTrail. If you see the API in your logs, you must create a new scheduled action to resume scheduled scaling.
Note that there might be a delay of a few seconds between your configured start time and the actual start time.
If the scheduled action was triggered but didn't make the required changes:
Check for suspended processes (such as Launch or Terminate). If there are any suspended processes, you can resume them.
If dynamic scaling policies are configured: Check the activity history for any scaling event caused by the dynamic scaling policies. Check the history at a few minutes before and after the scheduled action's start time. If there was such activity, it might have overridden the scheduled action.
Check the activity history around the scheduled action's start time. If there's another scheduled action configured to trigger in a similar time period, confirm that it doesn't impact or override your new scheduled action. If necessary, update your scheduled actions to resolve these conflicts.
Check the activity history for any failed or canceled Launch or Terminate activities. If found, expand the failed/canceled event and review the Description for more details. For more information on troubleshooting these errors, see Troubleshooting Amazon EC2 Auto Scaling.
Note: Using scheduled actions to proactively scale an Auto Scaling group is helpful when you know the time frame for a one-time or recurring event. When you don't know the time frame of an event in advance, you can use the predictive scaling feature.