Scaling policies

Updated at:

A scaling group automatically adjusts resources to handle changes in application load, which ensures service stability and cost efficiency. When a scale-out or scale-in activity is triggered, the scaling policy determines which instances are added to or removed from the scaling group. Auto Scaling provides several preset scaling policies that you can configure in the console or by calling an API operation.

Scaling Policy Description

By default, a scaling group performs scaling activities based on the order of the vSwitches that you configure (the Priority policy). You can change the Scaling Policy to use another policy. Several scaling policies are preset for scaling groups:

Important

This configuration can be modified only when Type is ECS and Network Type is VPC. When Type is ECI, the default Scaling Policy is Priority.

  • Priority (the default policy).

    Scale based on the vSwitches that you define. If instances cannot be created in the zone of the higher-priority vSwitch, instances are automatically created in the zone of the next-priority vSwitch.

  • Distribution Balancing.

    Use this policy to keep the scaling group evenly distributed across zones after scaling activities and achieve multi-zone disaster recovery. If the number of ECS instances becomes unbalanced across zones due to reasons such as insufficient inventory, you can rebalance the instance distribution across zones. For more information, see Rebalance ECS instances.

  • Cost Optimization.

    Use the Cost Optimization policy to prioritize cost when the scaling group scales. When a scale-out activity occurs, the system attempts to create instances in ascending order of the vCPU unit price. If the scaling configuration specifies multiple instance types that use the spot billing method, the corresponding spot instances are created first. If none of the spot instance types can be created due to reasons such as insufficient inventory, the system automatically attempts to create instances on a pay-as-you-go basis. When a scale-in activity occurs, the instances with the highest vCPU unit price are removed first.

  • Custom Combination Policy.

    Customize the capacity distribution policy by using a combination of settings. You can use this policy to adjust the ratio of pay-as-you-go instances to spot instances in the scaling group, balance capacity across zones, and select instance types.

For information about how to configure this policy, see Configure a scaling policy .

Configure a scaling policy

Change the scaling policy of an existing scaling group

To change the Scaling Policy of an existing scaling group, perform the following steps:

  1. Log on to the Auto Scaling console.

  2. In the navigation pane on the left, click Scaling Groups.

  3. In the top navigation bar, select a region.

  4. On the Scaling Groups page, find the scaling group whose Scaling Policy you want to change. In the Actions column on the right, click Edit. The Edit Scaling Group dialog box appears.

  5. Set Scaling Policy to the policy that you want.

    If you select Distribution Balancing, Cost Optimization, or Custom Combination Policy, you must further complete the child configuration items. For more information about the child configuration items, see Sub-configuration Item Description.

  6. Click OK to complete the configuration.

Configure the scaling policy when you create a scaling group

You can configure the Scaling Policy when you create a scaling group, as shown in the following figure.

Scaling Policy configuration in the create scaling group form

If you select Cost Optimization or Custom Combination Policy, you must further complete the child configuration items. For more information about the child configuration items, see Sub-configuration Item Description.

Sub-configuration Item Description

If you set the scaling policy to Distribution Balancing, Cost Optimization, or Custom Combination Policy, refer to the following tables to complete the configuration.

Balanced Distribution Policy

Configuration item

Description

Balanced Mode

  • Best-effort Delivery: the default delivery mode. If creation fails in a zone due to resource limits, the system falls back to other zones.

  • Balanced Only: if creation fails in a zone due to resource limits, the system does not fall back to other zones.

Enable Auto-rebalance

After this feature is enabled, the scaling group automatically detects zone capacity. When the zone capacity is unbalanced, the scaling group proactively scales across zones to rebalance the zone capacity.

Cost Optimization Policy

Configuration item

Description

Minimum Number of Pay-as-you-go Instances

The minimum number of pay-as-you-go ECS instances required by the scaling group. Default value: 0. If the number of pay-as-you-go ECS instances in the scaling group is less than this value, pay-as-you-go instances are created first.

Percentage of Pay-as-you-go Instances

The percentage of pay-as-you-go instances among the ECS instances that are automatically created. Default value: 70%. The instances that correspond to the minimum number of pay-as-you-go instances in the scaling group are excluded when this value is calculated.

Lowest Cost Instance Types

The number of instance types with the lowest price. Default value: 1. This setting takes effect when multiple optional instance types are specified in the scaling configuration. When spot instances are created, the scaling group evenly creates ECS instances across the instance types with the lowest prices.

Enable Supplemental Spot Instances

After supplemental spot instances are enabled, the scaling group proactively creates a new spot instance and replaces the spot instance that is about to be reclaimed 5 minutes before the reclamation.

Use Pay-as-you-go Instances to Supplement Spot Capacity

Enabled by default. If the required spot instance capacity cannot be met due to reasons such as price or inventory, enabling this feature allows the scaling group to attempt to create pay-as-you-go instances to meet the current spot instance capacity.

Replace Pay-as-you-go Instance with Spot Instance

After Use Pay-as-you-go Instances to Supplement Spot Capacity is enabled, the percentage of pay-as-you-go instances in the scaling group may exceed the Percentage of Pay-as-you-go Instances. You can enable this option. After it is enabled, the scaling group attempts to replace pay-as-you-go instances with spot instances.

Custom Combination Policy

Configuration item

Description

Minimum Number of Pay-as-you-go Instances

The minimum number of pay-as-you-go ECS instances required by the scaling group. Default value: 0. If the number of pay-as-you-go ECS instances in the scaling group is less than this value, pay-as-you-go instances are created first.

Percentage of Pay-as-you-go Instances

The percentage of pay-as-you-go instances among the ECS instances that are automatically created. Default value: 70%. The instances that correspond to the minimum number of pay-as-you-go instances in the scaling group are excluded when this value is calculated.

Multi-zone Balanced Distribution

Note

Evenly distributes ECS instances across the multiple zones specified for the scaling group (that is, the multiple VPC vSwitches specified). You can rebalance the instance distribution across zones. For more information, see Rebalance ECS instances.

Capacity Planning Policy

The capacity planning policy determines how the scaling group selects available instance types to meet the capacity requirement.

  • Instance Type Configuration Order: creates instances in the configured order of instance types.

  • Lowest Price: creates instances in ascending order of the vCPU unit price of the instance types.

Configure Spot Capacity Planning Policy

After this option is enabled, you can specify a separate capacity planning policy for spot instances.

Spot Capacity Planning Policy

Same as Capacity Planning Policy.

Lowest Cost Instance Types

Specifies the number of instance types with the lowest price. When spot instances are created, they are evenly distributed across the specified instance types.

Enable Supplemental Spot Instances

After this feature is enabled, the current spot instance is proactively replaced approximately 5 minutes before it is reclaimed.

Use Pay-as-you-go Instances to Supplement Spot Capacity

Enabled by default. If the required spot instance capacity cannot be met due to reasons such as price or inventory, enabling this feature allows the scaling group to attempt to create pay-as-you-go instances to meet the current spot instance capacity.

Replace Pay-as-you-go Instance with Spot Instance

After Use Pay-as-you-go Instances to Supplement Spot Capacity is enabled, the percentage of pay-as-you-go instances in the scaling group may exceed the Percentage of Pay-as-you-go Instances. You can enable this option. After it is enabled, the scaling group attempts to replace pay-as-you-go instances with spot instances.

Modify a scaling policy by calling an API operation

You can change the scaling policy of a scaling group by calling an API operation. This topic uses the ModifyScalingGroup operation as an example. Different policies require different parameters. The following sections describe the parameters to set for each scaling policy.

Set the priority policy

Scale out or scale in according to the vSwitches you define. If an instance cannot be created in the zone where a higher-priority vSwitch is located, an instance will be automatically created in the zone of the next-priority vSwitch.

Parameter name

Data type

Description

How to set

ScalingGroupId

string

The ID of the scaling group. (Required)

Set this parameter to the ID of the scaling group that you want to change.

MultiAZPolicy

string

The scaling policy. (Required)

To implement the Priority policy, set this parameter to PRIORITY.

Set the balanced distribution policy

Set the following parameters to implement the Distribution Balancing policy:

Important

A scaling group must be configured with vSwitches in multiple zones in order to create instances across multiple zones.

Parameter name

Data type

Description

How to set

ScalingGroupId

string

The ID of the scaling group. (Required)

Set this parameter to the ID of the scaling group that you want to change.

MultiAZPolicy

string

The scaling policy. (Required)

To implement the Distribution Balancing policy, set this parameter to BALANCE.

BalanceMode

string

The balanced mode. (Optional)

Valid values:

  • BalancedBestEffort: Best-effort Delivery. If resource creation fails in a zone, the system falls back to other zones to ensure best-effort delivery of resources.

  • BalancedOnly: if creation fails in a zone due to resource limits, the system does not fall back to other zones.

Default value:BalancedBestEffort.

AutoRebalance

boolean

Specifies whether to enable automatic rebalancing. (Optional)

After this feature is enabled, the scaling group automatically detects zone capacity. When the zone capacity is unbalanced, the scaling group proactively scales across zones to rebalance the zone capacity.

This parameter takes effect only when BalanceMode=BalancedOnly.

Valid values:

  • false: Disabled

  • true: Enabled

Default value:false.

If instances become unbalanced across zones due to reasons such as insufficient inventory, you can manually call the related API operation to rebalance the instance distribution. For more information, see RebalanceInstances.

Set the cost optimization policy

Attempt to create instances in ascending order of vCPU unit price. After the scaling configuration is set to , the system first tries to create spot instances; if that fails, it then tries to create pay-as-you-go instances.

Important

Cost optimization policies can only take effect after you configure multiple instance types or enable preemptible instances in the scaling configuration.

Parameter name

Data type

Description

How to set

ScalingGroupId

string

The ID of the scaling group. (Required)

Set this parameter to the ID of the scaling group that you want to change.

MultiAZPolicy

string

The scaling policy. (Required)

To implement the Cost Optimization policy, set this parameter to COST_OPTIMIZED.

OnDemandBaseCapacity

integer

The minimum number of pay-as-you-go instances in the scaling group. (Optional) When the number of pay-as-you-go instances in the scaling group is less than this value, the system creates pay-as-you-go instances first.

Set this parameter based on your business requirements. Valid values: 0 to 1000. Default value: 0.

OnDemandPercentageAboveBaseCapacity

integer

The percentage of pay-as-you-go instances. (Optional) The percentage of pay-as-you-go instances among the instances that exceed the minimum number of pay-as-you-go instances specified by OnDemandBaseCapacity.

Set this parameter based on your business requirements. Valid values: 0 to 100. Default value: 0.

SpotInstancePools

integer

The number of instance types with the lowest price. It takes effect when multiple optional instance types are specified in the scaling configuration. When spot instances are created, the scaling group evenly creates ECS instances across the instance types with the lowest prices.

Set this parameter based on your business requirements. Valid values: 0 to 10. Default value: 2.

SpotInstanceRemedy

boolean

Specifies whether to enable supplemental spot instances. After supplemental spot instances are enabled, the scaling group proactively creates a new spot instance and replaces the spot instance that is about to be reclaimed 5 minutes before the reclamation.

Set this parameter based on your business requirements. Valid values:true, false.

CompensateWithOnDemand

boolean

Specifies whether to enable the use of pay-as-you-go instances to supplement spot capacity. When enabled, the system automatically attempts to create pay-as-you-go instances to meet the required number of ECS instances if sufficient spot instances cannot be created due to reasons such as price or inventory.

Set this parameter based on your business requirements. Valid values:true, false.

CapacityOptions.SpotAutoReplaceOnDemand

boolean

Specifies whether to enable the automatic replacement of pay-as-you-go instances with spot instances. After CompensateWithOnDemand is enabled, if the percentage of pay-as-you-go instances exceeds the value of OnDemandPercentageAboveBaseCapacity, the system attempts to use spot instances to replace the pay-as-you-go capacity.

Set this parameter based on your business requirements. Valid values:true, false.

Set the custom combination policy

Set the following parameters to implement the Custom Combination Policy:

Parameter name

Data type

Description

How to set

ScalingGroupId

string

The ID of the scaling group. (Required)

Set this parameter to the ID of the scaling group that you want to change.

MultiAZPolicy

string

The scaling policy. (Required)

To implement the Custom Combination Policy, set this parameter to COMPOSABLE.

OnDemandBaseCapacity

integer

The minimum number of pay-as-you-go instances in the scaling group. (Optional) When the number of pay-as-you-go instances in the scaling group is less than this value, the system creates pay-as-you-go instances first.

Set this parameter based on your business requirements. Valid values: 0 to 1000. Default value: 0.

OnDemandPercentageAboveBaseCapacity

integer

The percentage of pay-as-you-go instances. (Optional) The percentage of pay-as-you-go instances among the instances that exceed the minimum number of pay-as-you-go instances specified by OnDemandBaseCapacity.

Set this parameter based on your business requirements. Valid values: 0 to 100. Default value: 100.

AzBalance

boolean

Specifies whether to enable multi-zone balanced distribution. (Optional) Evenly distributes ECS instances across the multiple zones specified for the scaling group (that is, the multiple VPC vSwitches specified). If the zones become unbalanced due to reasons such as insufficient inventory, you can call the related API operation to rebalance them. For more information, see RebalanceInstances.

Set this parameter based on your business requirements. Valid values:true, false.

AllocationStrategy

string

The capacity planning policy. (Optional) Determines how the scaling group selects available instance types to meet the capacity requirement.

Set this parameter based on your business requirements. Valid values: - priority (default): creates instances in the configured order of instance types. - lowestPrice: creates instances in ascending order of the vCPU unit price of the instance types.

SpotAllocationStrategy

string

Specifies a separate capacity planning policy for spot instances. (Optional)

Set this parameter based on your business requirements. Valid values: - priority: creates instances in the configured order of instance types. - lowestPrice: creates instances in ascending order of the vCPU unit price of the instance types.

SpotInstancePools

integer

The number of instance types with the lowest price. This field must be set when the value of AllocationStrategy or SpotAllocationStrategy is lowestPrice. It takes effect when multiple optional instance types are specified in the scaling configuration. When spot instances are created, the scaling group evenly creates ECS instances across the instance types with the lowest prices.

Set this parameter based on your business requirements. Valid values: 0 to 10. Default value: 2.

SpotInstanceRemedy

boolean

Specifies whether to enable supplemental spot instances. This field must be set when the value of AllocationStrategy or SpotAllocationStrategy is lowestPrice. After supplemental spot instances are enabled, the scaling group proactively creates a new spot instance and replaces the spot instance that is about to be reclaimed 5 minutes before the reclamation.

Set this parameter based on your business requirements. Valid values:true, false.

CompensateWithOnDemand

boolean

Specifies whether to enable the use of pay-as-you-go instances to supplement spot capacity. This field must be set when the value of AllocationStrategy or SpotAllocationStrategy is lowestPrice. When enabled, the system automatically attempts to create pay-as-you-go instances to meet the required number of ECS instances if sufficient spot instances cannot be created due to reasons such as price or inventory.

Set this parameter based on your business requirements. Valid values:true, false.

CapacityOptions.SpotAutoReplaceOnDemand

boolean

Specifies whether to enable the automatic replacement of pay-as-you-go instances with spot instances. After CompensateWithOnDemand is enabled, if the percentage of pay-as-you-go instances exceeds the value of OnDemandPercentageAboveBaseCapacity, the system attempts to use spot instances to replace the pay-as-you-go capacity.

Set this parameter based on your business requirements. Valid values:true, false.