Scheduled Scaling using ASG for Predictable Load Changes

2022.03.27

この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。

There is an Event and you are likely to expect increase traffic on your website, a monthly sale and you know for this particular day you can predict load changes on your web server or there is a launch of new feature and you know that on this day there will spike in traffic but the very next day traffic would be less. The common attribute of all such events is the time component.

Amazon EC2 Auto Scaling helps you to configure and automate scaling on the basis of schedule according to predictable load changes.

This article talks about scheduled actions where scaling activity happens as function of date and time.

Do checkout Cloud Architect Perspective for Scheduled Scaling with ASG

What is Scheduled Scaling for ASG?

  • Based on Predictable load changes, scheduled scaling allows to set up scaling on your desired day and time.

  • To set up scheduled scaling we use ASG's scheduled action feature, which simply scales in or sclaes out the the ec2 instances on your desired date and time.

Considerations for scheduled action

  • Coordinated Universal Time (UTC) is the time zone for recurring schedules.When you specify a time zone that observes Daylight Saving Time (DST), the action automatically adjusts for DST.
  • Events can occur montly or weekly, hence it makes sense to keep scheduled actions when needed rather than creating them everytime.Temporarily turn off scheduled scaling for an Auto Scaling group by suspending the ScheduledActions process. This helps you prevent scheduled actions from being active without having to delete them. You can then resume scheduled scaling when you want to use it again.
  • Scheduled Action when in action has its own min, max and desired capacity for the period scheduled action is active, once scheduled Action is over, min,max,desired defaults to value set for entire ASG.

Recurring Schedule

  • Recurring scheduled actions are created by using cron expression format.
  • To set up recurring schedule in Management Console, specify the recurrence pattern, time zone, start time, and optional end time of your scheduled action.

NOTE:- - If you specify a start time, Amazon EC2 Auto Scaling performs the action at this time, and then performs the action based on the specified recurrence.

  • A recurring action never repeats once it has reached its end time.

Set up Scheduled Action

  • Create a Launch Template, and specify template in ASG config launchTemplate

    addLT

  • Add Network and group size configuration

    Network

    GroupSize

  • Auto scaling launched a single instance based on config

    singleInstance

  • Select scheduled action and set schedule action for scaling out and scaling in

    scheduled action

  • Here, we are selecting to scale out at 6:25 (IST) to 2 instances

    scale out

    increased instance

  • Here, we are selecting to scale in at 6:30 (IST) to 1 instances

    scale in

  • Summary of scaling activity

    scaling activity

Cloud Architect Perspective

  • A scheduled action must have a unique time value. if there is another scaling activity at the same there will be an error.
  • You can create a maximum of 125 scheduled actions per Auto Scaling group.

When you can anticipate the load changes on your web server or there is a launch of new feature and you know that on this day there will spike in traffic but the very next day traffic would be less, then scheduled action for asg can be a real lifesaver both in terms of customer experience, application availability performance and cost.

Till then, Happy Learning!