Configure instance count using a scheduled task
This topic describes how to use a scheduled task to periodically change the maximum, minimum, and expected instances in a scaling group.
Background information
You can configure or change the number of instances in a scaling group, including the maximum, minimum, and expected instances, using one of two methods. This topic focuses on the second method: using a scheduled task.
-
Method 1: When you create a scaling group, you can configure the number of instances. You can also change the maximum, minimum, or expected instances after the scaling group is created. For more information, see Configure a scaling group.
-
Method 2: When you create a scheduled task, you can configure the number of instances for the scaling group. You can also change the maximum, minimum, or expected instances after the task is created.
When a scheduled task is executed, the number of instances in the scaling group depends on its parameter settings.
-
If you do not use a scheduled task to configure the number of instances, the system maintains the current number of instances in the scaling group.
-
If you use a scheduled task to configure the number of instances, the configured values update the scaling group's current instance counts. The maximum instances, minimum instances, and expected instances must meet the following constraints:
-
minimum instances ≤ maximum instances.
-
minimum instances ≤ expected instances
-
expected instances ≤ maximum instances.
If these constraints are not met when a scheduled task is executed, the scaling activity fails.
-
Scenario 1: The scaling activity fails because the minimum number of instances is greater than the maximum number of instances.
For example, a scaling group has a maximum of 2 instances and a minimum of 0 instances. A scheduled task attempts to set the minimum instances to 3. The scaling activity fails because the new minimum instances (3) is greater than the maximum instances (2).
-
Scenario 2: The scaling activity fails because the minimum number of instances is greater than the number of expected instances.
For example, a scaling group has a maximum of 10 instances, a minimum of 0 instances, and 5 expected instances. A scheduled task attempts to set the minimum instances to 6. The scaling activity fails because the new minimum instances (6) is greater than the expected instances (5).
-
Scenario 3: The scaling activity fails because the number of expected instances is greater than the maximum number of instances.
For example, a scaling group has a maximum of 5 instances, a minimum of 0 instances, and 3 expected instances. A scheduled task attempts to set the number of expected instances to 6. The scaling activity fails because the new expected instances (6) is greater than the maximum instances (5).
-
Notes
-
When you create or modify a scheduled task, you cannot select Select an existing rule and Configure the number of instances in a scaling group at the same time. You can specify only one scaling method.
-
When you set the maximum, minimum, and expected instances for a scheduled task, you must set at least one of these parameters. If you set multiple parameters, you must ensure that they meet the condition: minimum instances ≤ expected instances ≤ maximum instances.
-
You cannot set the expected instances when creating or modifying a scheduled task if this feature was not enabled when you created the scaling group.
-
For scaling groups with the expected instances feature enabled, set the maximum, minimum, and expected instances together in the scheduled task to ensure it runs correctly.
Procedure
Log on to the Auto Scaling console.
In the navigation pane on the left, click .
In the top navigation bar, select a region.
-
Click Create Scheduled Task.
-
On the Create Scheduled Task page, configure the parameters.
For Scaling Method, select Configure the number of instances in a scaling group. Then, set Maximum Instances, Minimum Instances, and Expected Instances. For more information about how to configure other parameters, see Configure scheduled tasks.
NoteYou can set or modify the Expected Instances only if you enabled this feature when you created the scaling group. Otherwise, you can set or modify only the Maximum Instances and Minimum Instances.
-
Click OK.
-
View the details of the scaling activity.
After the scheduled task is executed, go to the scaling activity details page to view the changes to the number of instances in the scaling group. For more information about how to view scaling activities, see View the details of a scaling activity. The scaling activity details panel displays fields such as Status (for example, "Successful"), Start Time, Stop Time, Cause, Details (for example, the IDs of started ECS instances), Total Instances After Change, Status Message (for example, "0 ECS instances are added, 1 ECS instance is started"), and Description (for example, Add 1 ECS instance). The Instance Details tab at the bottom of the panel provides more information about the associated instances.