Advanced features - Instance Scheduler on AWS

Advanced features

EC2 Auto Scaling Group scheduling

Instance Scheduler on AWS supports scheduling of EC2 Auto Scaling groups (ASGs) using Scheduled Scaling Actions. This differs from the implementation of EC2/RDS scheduling and will be further explained in this section

Refer to Scheduled scaling for Amazon EC2 Auto Scaling for more information on Scheduled Scaling Actions.

ASG scheduling overview

ASGs can be scheduled by applying a schedule tag as described in Tagging instances for scheduling

Scheduled scaling rules will then be managed for your ASG by two systems:

First, an ASG orchestrator Lambda function runs hourly and initiates an ASG handler function for each of your scheduled accounts/regions. This function will look for newly tagged ASGs or ASGs whose configured scheduled scaling actions have become stale. It will then reconfigure all scheduled scaling actions that start with the ASG action name prefix (specified at solution deployment) to match the associated schedule.

Second, when a schedule is updated in the scheduler configuration table, a DynamoDB stream will initiate (via the Schedule Update Handler Lambda function) addition ASG handler requests that will update the scheduled scaling actions on all ASGs tagged with the newly updated schedule.

Definition of Running/Stopped for ASGs

When an Auto Scaling Group is configured, a user specifies a minimum, desired, and maximum capacity for that ASG. Instance Scheduler refers to these values as the min-desired-max of an ASG.

When Instance Scheduler first configures Scheduled Scaling Actions for an ASG, the currently configured min-desired-max values will be used to define the running state of the ASG. If the ASG is currently configured with a min-desired-max of 0-0-0, Instance Scheduler will report an error and will not configure any Scheduled Scaling Actions until a new min-desired-max has been configured that can be used to define a running state for the ASG.

When updating the Scheduled Scaling Actions for an ASG, Instance Scheduler will look at the current min-desired-max at the time of the update and use those values to define the new running state for the schedule. If the min-desired-max is currently 0-0-0 at the time of the update, the previous running state will be used.

For all ASGs the stopped state is defined as a min-desired-max of 0-0-0.

ASG Scheduled Tag

When an auto scaling group is scheduled by the solution, an auto scaling group scheduled tag is added to the auto scaling group. The tag contains the below information in JSON format:

Key Value Type Value
schedule String Schedule name aligned with the scheduler configuration table.
ttl String Until when the tag is valid.
min_size Integer Auto scaling group min size when scheduled.
max_size Integer Auto scaling group max size when scheduled.
schedule Integer Auto scaling group desired capacity when scheduled.

The presence of a valid Scheduled Tag that has not yet expired its TTL indicates to Instance Scheduler that an ASG has been correctly configured for scheduling. This tag can be manually deleted to forcefully cause Instance Scheduler to reconfigure Scheduled Scaling Actions on an ASG during the next ASG scheduling run.

Limitations

ASG scheduling is performed by converting Instance Scheduler on AWS schedules into scheduled scaling rules compatible with the ASG service. This translation works best for simple single-period schedules that do not use complex cron expressions.

The following schedule features are not supported for ASG scheduling:

  • Advanced schedule flags such as enforced and retain running.

  • Nth weekday, nearest weekday, and last weekday expressions in periods.

  • Multi-period schedules with immediately adjacent or overlapping periods.*

*when configuring scheduled scaling actions for multi-period schedules, Instance Scheduler on AWS directly translate the beginning/end of periods to start/stop actions for the ASG even when another overlapping or adjacent period would normally cause that action to be skipped.