Scheduled Scaling allows us to inform the ASG when it should launch additional instances and when it should remove instances. This type of scaling is suitable for workloads that fluctuate over a certain period, recurring daily, and over a long period.
Since we’ve already set up the testing in the previous section, we don’t need to set it up again, and we can continue using those settings.
Go to the ASG information page, navigate to the “Automatic scaling” tab, and scroll to the bottom.
Under the “Scheduled actions” section, click Create scheduled action.
A form will appear. Fill in the details as follows:
Rush hour
.The parameters for Desired capacity, Min, and Max will all affect the corresponding ASG parameters, so in practice, you will need to combine multiple scaling types and carefully consider these settings.
Successfully created.
Approximately 5 minutes before the ASG launches instances as scheduled, we should run the test program.
After a few minutes, when the scheduled time for ASG to launch new instances arrives, go to the Activity tab to monitor ASG actions. You’ll see the Executing scheduled action Rush hour event triggered at the right time, and then the ASG launches a new instance.
Returning to the EC2 Console, metrics are updated every 15 minutes. When you revisit to observe these metrics, focus on the CPU Utilization chart. You can see that between 14:30 and 14:40, there is a spike, which was caused when we started the test program.
Wait a few more minutes for these metrics to update. Once updated, select the newly launched instance.
You will notice that after 14:40, the chart declines.
Zoom in on this chart:
You’ll see the changes more clearly.
In reality, trading platforms often experience peak user traffic at certain times of the day. This increase in traffic is similar to rush hour in transportation, where traffic rises at a specific time each day and repeats daily for a long period. In such cases, we need to schedule new instances to handle the load.
However, in practice, we will need to combine this with other types of scaling to enhance the reliability of the system.