This topic introduces the Expected Instances feature. You can use the feature to specify the expected number of instances to execute parallel scaling activities.

Feature introduction

After the expected number of instances are specified, the scaling group will automatically keep the number of ECS instances at the expected value. The Expected Instances feature solves the following problems:
  • When a scaling activity fails to execute, you must execute again manually.
  • When a scaling activity is being executed, other scaling activities cannot be executed.
To enable the Expected Instances feature, you must specify the Expected Instances field when creating a scaling group. The specified expected number of instances in the scaling group can be modified.
Note The Expected Instances feature can be enabled only when you create a scaling group. You cannot enable the feature by modifying the number of instances in an existing scaling group.
The following table describes the terms for Expected Instances.
Term Description
stable instance The instance that is in the InService, Protected, or Standby state in a scaling group.
parallel scaling activity The scaling activity that can be executed in parallel with other scaling activities in a scaling group. The parallel scaling activities include:
  • Executing scaling rules manually or by using scheduled tasks.
  • Manually adding or removing ECS instances.
  • Performing expected instances check, health check, minimum instances check, and maximum instances check.
non-parallel scaling activity The scaling activity that cannot be executed in parallel with other scaling activities. A scaling activity that is not a parallel activity is a non-parallel scaling activity. The non-parallel scaling activities include:
  • Executing a scaling rule by using the event-triggered task.
  • Manually executing the re-balancing task.
  • Executing the task of supplementing preemptible instances.

Limits

  • After the Expected Instances feature of a scaling group is enabled, the feature cannot be disabled.
  • The expected number of instances in a scaling group must range from the minimum number to the maximum number of ECS instances.

Rules for expected instances

Apart from manually specifying the expected number of instances, you can also change the expected number of instances by executing scaling activities. The change is related to how the scaling activities are triggered.

Scaling activity type Method for triggering scaling activity Scaling activity effect Change of expected instances Example
Parallel scaling activity Manually execute a scaling rule Only the expected number of instances is changed. Wait for Auto Scaling to perform the expected instances check to determine whether to add or remove instances. Number of stable instances plus or minus Number of added or removed instances Scenario:
  • Current expected instances: 3
  • Current stable instances: 2
  • A scaling rule is executed to automatically create 4 ECS instances.

Result:

The expected number of instances is changed to 6, but the ECS instances are not created immediately. Wait for Auto Scaling to perform the expected instances check to add or remove instances.

Execute a scaling rule by using the scheduled task Only the expected number of instances is changed. Wait for Auto Scaling to perform the expected instances check to determine whether to add or remove instances. Number of stable instances plus or minus Number of added or removed instances Scenario:
  • Current expected instances: 3
  • Current stable instances: 2
  • A scaling rule is executed to automatically create 4 ECS instances.

Result:

The expected number of instances is changed to 6, but the ECS instances are not created immediately. Wait for Auto Scaling to perform the expected instances check to add or remove instances.

Manually add ECS instances The ECS instances are added immediately, and the expected number of instances is changed. Number of current expected instances plus Number of manually added instances Scenario:
  • Current expected instances: 3
  • Current stable instances: 2
  • Manually add 4 existing ECS instances

Result:

4 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 ECS instances are removed immediately, and the expected number of instances is changed. Number of current expected instances minus Number of manually removed instances Scenario:
  • Current expected instances: 3
  • Current stable instances: 2
  • Manually remove 1 ECS instance

Result:

1 ECS 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 check on maximum and minimum instances - The expected number of instances must be specified manually Scenario:
  • Current maximum instances: 5
  • Current minimum instances: 0
  • Current expected instances: 3
  • Current stable instances: 2
  • Try to modify the maximum number of ECS instances to 1.

Result:

Modification failed. You must modify the expected number of instances at the same time.

Perform health check on ECS instances The ECS instances are removed immediately. The expected number of instances remains unchanged Scenario:
  • Current expected instances: 3
  • Current stable instances: 2
  • 1 ECS instance is diagnosed as unhealthy

Result:

The expected number of instances remains unchanged. The unhealthy ECS instance is removed from the scaling group, and the number of stable instances is changed to 1. The scaling group can detect the difference between the expected number of instances and the number of stable instances, and then automatically execute the expected instances check to trigger the scaling activity to create 2 ECS instances.

Perform check on expected instances The ECS instances are added or removed immediately. The expected number of instances remains unchanged Scenario:
  • Current expected instances: 3
  • Current stable instances: 2

Result:

The expected number of instances remains unchanged. The scaling group can detect the difference between the expected number of instances and the number of stable instances, and then automatically execute the expected instances check to trigger the scaling activity to create 1 ECS instance.

Non-parallel scaling activity Execute a scaling rule by using the event-triggered task The ECS instances are added or removed immediately, and the expected number of instances is changed. Number of stable instances plus or minus Number of added or removed instances Scenario:
  • Current expected instances: 3
  • Current stable instances: 2
  • A scaling rule is executed to automatically create 4 ECS instances.

Result:

A scaling activity is triggered to create 4 ECS instances, and the expected number of instances is changed to 6.

Examples of parallel scaling activities

After the expected number of instances are specified, the scaling group can execute parallel scaling activities at the same time.
  • Example 1: Manually execute scaling rules continuously
    Scenario:
    • Expected instances: 3
    • Stable instances: 3
    • The scaling rule add3 can create 3 ECS instances.
    • The scaling rule add1 can create 1 ECS instance.
    • Manually execute the scaling rule add3 first and then the scaling rule add1 immediately.
    Result: After the scaling rule add3 is executed, the expected number of instances is changed from 3 to 6. The scaling rule add1 is executed immediately, and the expected number of instances is changed from 6 to 4. The result of executing parallel scaling activities is that 1 ECS instance is created.
  • Example 2: Manually execute a scaling rule and manually add ECS instances
    Scenario:
    • Expected instances: 3
    • Stable instances: 3
    • The scaling rule add1 can create 1 ECS instance.
    • Manually execute the scaling rule add1 first, and then manually add 1 existing ECS instance immediately.
    Result: After the scaling rule add1 is executed, the expected number of instances is changed from 3 to 4. Manually add 1 existing ECS instance immediately, and the expected number of instances is changed from 4 to 5. The result of executing parallel scaling activities is that 1 ECS instance is created and 1 existing ECS instance is added.

Examples of non-parallel scaling activities

After the expected instances are specified, the scaling group cannot execute parallel scaling activities and non-parallel scaling activities at the same time.

Scenario:
  • Expected instances: 1
  • Stable instances: 1
  • The event-triggered task can create 3 ECS instances.
  • The scaling rule add1 can create 1 ECS instance.
  • After the event-triggered task is triggered, manually execute the scaling rule add1 immediately.
Result: After a scaling activity is triggered by the event-triggered task, the expected number of instances is changed from 1 to 4. The scaling activity triggered by the event-triggered event is a non-parallel scaling activity, and other parallel scaling activities cannot be executed immediately. The scaling rule add1 cannot be executed immediately, and the expected number of instances is still 4.