This topic describes the Expected Number of Instances feature and how to specify the expected number of instances in a scaling group to execute parallel scaling activities.
Overview
To enable the Expected Number of Instances feature, you must set the Expected Number of Instances parameter when you create a scaling group. You can change the specified expected number of instances in the scaling group after the scaling group is created. After you specify the expected number of instances in a scaling group, when the number of instances in the scaling group is not equal to the expected number of instances, Auto Scaling automatically adjusts the number of instances to ensure that the number of instances in the scaling group is maintained at the expected number.
If you do not enable the Expected Number of Instances feature, you may encounter the following problems:
- You must manually retry failed scaling activities.
- Auto Scaling rejects requests to execute new scaling activities in the scaling group. The utilization of the scaling group is not maximized. For example, if the health check feature triggers a scaling activity in a scaling group while the scaling group has an ongoing scaling activity, Auto Scaling rejects the scaling activity triggered by the health check feature.
Term | Description |
---|---|
stable instance | An instance that is in the In Service, Protected, or Standby state in a scaling group. |
parallel scaling activity | A scaling activity that can be executed in parallel with other ongoing scaling activities
in a scaling group. Parallel scaling activities can be triggered by the following
actions:
|
non-parallel scaling activity | A scaling activity that cannot be executed in parallel with other ongoing scaling
activities. A scaling activity that is not a parallel activity is a non-parallel scaling
activity. Non-parallel scaling activities can be triggered by the following actions:
|
Limits
- You cannot disable the Expected Number of Instances feature for a scaling group after you enable the feature.
- Scaling groups for which an expected number of instances is specified cannot have parallel scaling activities and non-parallel scaling activities at the same time.
- If you do not specify an expected number of instances when you create a scaling group, you cannot edit the Expected Number of Instances parameter for the scaling group.
- You must set Expected Number of Instances to a value that ranges from the value of Minimum Number of Instances to the value of Maximum Number of Instances in a scaling group.
Differences between scaling groups with an expected number of instances and scaling groups without an expected number of instances
The following table describes the differences between scaling groups for which an expected number of instances is specified and scaling groups for which an expected number of instances is not specified.
Item | With an expected number of instances | Without an expected number of instances |
---|---|---|
Maintenance costs | Automatic maintenance: Auto Scaling automatically scales instances to maintain the expected number of instances in a scaling group. If a scaling activity fails in the scaling group, Auto Scaling automatically retries the failed scaling activity. | Manual maintenance: You need to manually adjust the number of instances in a scaling group. If a scaling activity fails in the scaling group, you need to manually retry the failed scaling activity. |
Execution results of scaling activities | The execution results of scaling activities vary based on how the scaling rules are
executed.
|
If you manually execute a scaling rule, use an event-triggered task or scheduled task to execute the scaling rule, manually add instances to or remove instances from a scaling group, or manually delete instances, Auto Scaling immediately triggers the scaling activity to add or remove instances. |
Parallel execution | Scaling groups can have parallel scaling activities. For more information, see Examples of parallel scaling activities. | A scaling group can have only one ongoing scaling activity at a time. The scaling activity may take a long time. When the scaling activity is being executed, you cannot adjust the number of instances in the scaling group. |
Rules for changes to the expected number of instances
You can specify the expected number of instances. You can also manually trigger scaling activities to change the expected number of instances. The changes take effect based on how the scaling activities are triggered.
Scaling activity type | Method to trigger a scaling activity | Scaling activity result | New expected number of instances | Examples |
---|---|---|---|---|
Parallel scaling activity | Manually execute the scaling rule. | Only the expected number of instances is changed. You must wait for Auto Scaling to perform a check on the expected number of instances to determine whether to add or remove instances. | Number of stable instances ± Number of added or removed instances | Scenario:
Result: The expected number of instances is changed to 6, but the ECS instances are not immediately created. You must wait for Auto Scaling to perform a check on the expected number of instances to determine whether to add or remove instances. |
Execute a scaling rule by using scheduled tasks | Only the expected number of instances is changed. You must wait for Auto Scaling to perform a check on the expected number of instances to determine whether to add or remove instances. | Number of stable instances ± Number of added or removed instances | Scenario:
Result: The expected number of instances is changed to 6, but the ECS instances are not immediately created. You must wait for Auto Scaling to perform a check on the expected number of instances to determine whether to add or remove instances. |
|
Manually add instances | The instances are immediately added, and the expected number of instances is changed. | Current expected number of instances + Number of manually added instances | Scenario:
Result: Four ECS instances are added to the scaling group. The number of stable instances is changed to 6, and the expected number of instances is changed to 7. |
|
Manually remove ECS instances | The instances are immediately removed, and the expected number of instances is changed. | Current expected number of instances - Number of manually removed instances | Scenario:
Result: One instance is removed from the scaling group. The number of stable instances is changed to 1, and the expected number of instances is changed to 2. |
|
Perform checks on the minimum and maximum numbers of instances | - | To be manually specified | Scenario:
Result: The maximum number failed to be changed. You must change the expected number of instances at the same time. |
|
Perform health checks on instances | The instances are immediately removed from the scaling group. | The expected number of instances remains unchanged | Scenario:
Result: The expected number of instances remains unchanged. The unhealthy instance is removed from the scaling group, and the number of stable instances is changed to 1. Auto Scaling detects the difference between the expected number of instances and the number of stable instances, and then automatically performs a check on the expected number of instances to trigger the scaling activity to create two ECS instances. |
|
Perform a check on the expected number of instances | The instances are immediately added to or removed from the scaling group. | The expected number of instances remains unchanged | Scenario:
Result: The expected number of instances remains unchanged. Auto Scaling detects the difference between the expected number of instances and the number of stable instances, and then automatically performs a check on the expected number of instances to create one ECS instance. |
|
Non-parallel scaling activity | Execute a scaling rule by using event-triggered tasks | The instances are immediately added to or removed from the scaling group, and the expected number of instances is changed. | Number of stable instances ± Number of added or removed instances | Scenario:
Result: A scaling activity is triggered to create four instances, and the expected number of instances is changed to 6. |
Examples of parallel scaling activities
- Example 1: Manually execute scaling rules in a consecutive manner
Scenario:
- Expected number of instances: 3.
- Number of stable instances: 3.
- The add3 scaling rule specifies to create three ECS instances.
- The add1 scaling rule specifies to create one ECS instance.
- Manually execute the add3 scaling rule and then immediately execute the add1 scaling rule.
Result: After the add3 scaling rule is executed, the expected number of instances is changed from 3 to 6. The add1 scaling rule is immediately executed, and the expected number of instances is changed from 6 to 4. After the parallel scaling activity is executed, one instance is created and the number of stable instances in the scaling group is changed to 4. - Example 2: Manually execute a scaling rule and manually add instances
Scenario:
- Expected number of instances: 3.
- Number of stable instances: 3.
- The add1 scaling rule specifies to create one ECS instance.
- Manually execute the add1 scaling rule and then immediately add an existing ECS instance.
Result: After the add1 scaling rule is executed, the expected number of instances is changed from 3 to 4. One existing ECS instance is immediately added to the scaling group, and the expected number of instances is changed from 4 to 5. After the parallel scaling activity is complete, one ECS instance is created, one existing ECS instance is added, and the number of stable instances in the scaling group is changed to 5.
Examples of non-parallel scaling activities
After you specify the expected number of instances, Auto Scaling cannot execute parallel and non-parallel scaling activities at the same time. Example:
- Expected number of instances: 1.
- Number of stable instances: 1.
- The scaling rule associated with an event-triggered task specifies to create three ECS instances.
- The add1 scaling rule specifies to create one ECS instance.
- After the event-triggered task is triggered, execute the add1 scaling rule immediately.
