0
0
AWScloud~5 mins

Scheduled scaling in AWS - Commands & Configuration

Choose your learning style9 modes available
Introduction
Scheduled scaling lets you automatically adjust the number of servers running your app at specific times. This helps save money by running fewer servers when traffic is low and adding more when traffic is high.
When you know your app gets more visitors every weekday morning and less at night.
When you want to reduce costs by lowering server count during weekends.
When you expect a big event and want to prepare by increasing servers beforehand.
When you want to automate scaling without waiting for traffic to trigger it.
When you want predictable server capacity changes based on time, not load.
Config File - scheduled-scaling.json
scheduled-scaling.json
{
  "AutoScalingGroupName": "my-app-asg",
  "ScheduledActionName": "scale-up-morning",
  "StartTime": "2024-07-01T08:00:00Z",
  "DesiredCapacity": 5,
  "MinSize": 2,
  "MaxSize": 10
}

This JSON file defines a scheduled scaling action for an AWS Auto Scaling group named my-app-asg. It sets the desired number of servers to 5 starting at 8 AM UTC on July 1, 2024. The minimum and maximum sizes ensure the group stays between 2 and 10 servers.

Commands
This command creates or updates a scheduled scaling action using the JSON file. It tells AWS when and how to change the number of servers.
Terminal
aws autoscaling put-scheduled-update-group-action --cli-input-json file://scheduled-scaling.json
Expected OutputExpected
No output (command runs silently)
--cli-input-json - Specifies the JSON file with the scheduled scaling details
This command shows all scheduled scaling actions for the Auto Scaling group to confirm the schedule was set.
Terminal
aws autoscaling describe-scheduled-actions --auto-scaling-group-name my-app-asg
Expected OutputExpected
{ "ScheduledUpdateGroupActions": [ { "AutoScalingGroupName": "my-app-asg", "ScheduledActionName": "scale-up-morning", "StartTime": "2024-07-01T08:00:00Z", "DesiredCapacity": 5, "MinSize": 2, "MaxSize": 10 } ] }
--auto-scaling-group-name - Specifies the Auto Scaling group to list scheduled actions for
Key Concept

If you remember nothing else from this pattern, remember: scheduled scaling lets you plan server count changes ahead of time based on clock, not traffic.

Common Mistakes
Setting the StartTime in local time instead of UTC.
AWS expects StartTime in UTC, so using local time causes the action to run at the wrong moment.
Always convert your local time to UTC before setting StartTime.
Not specifying MinSize and MaxSize in the scheduled action.
Without these, the Auto Scaling group might scale outside desired limits, causing unexpected costs or outages.
Always include MinSize and MaxSize to keep scaling within safe boundaries.
Forgetting to verify the scheduled action after creation.
If the schedule is incorrect or missing, your app won't scale as planned.
Run describe-scheduled-actions to confirm your schedule is set correctly.
Summary
Create a JSON file defining when and how to scale your Auto Scaling group.
Use the AWS CLI command to apply the scheduled scaling action from the JSON file.
Verify the scheduled action exists and is correct with a describe command.