Scaling policies

更新时间:
复制 MD 格式

A scaling group automatically adjusts resources to maintain service stability and cost-effectiveness as application load changes. During a scale-out or scale-in, Auto Scaling adds or removes instances from the scaling group based on a predefined scaling policy. Auto Scaling offers several predefined scaling policies. This topic explains how to configure them.

Scaling policies

By default, a scaling group scales instances based on the order of the vSwitches you configure. This behavior is called the priority policy. You can change the Scaling Policy to implement other strategies.

Important

You can modify this setting only when the Type is ECS and the Network Type is VPC. When the Type is ECI, the default Scaling Policy is the Priority.

  • Priority (default policy)

    Scales out or in based on the priority that you define for the vSwitches. During a scale-out event, the system first attempts to create an instance in the zone of the highest-priority vSwitch. If creation fails, the system automatically tries the zone of the next-highest priority vSwitch.

  • Distribution Balancing

    Use this policy to keep instances in your scaling group evenly distributed across multiple zones to help achieve multi-zone disaster recovery. If the number of ECS instances becomes unbalanced across zones for reasons such as insufficient inventory, you can perform a rebalance. For more information, see Rebalance ECS instances.

  • Cost Optimization

    Use the Cost Optimization when cost is a high priority. During a scale-out, this policy attempts to launch instances in ascending order of their vCPU unit price. If the scaling configuration includes multiple instance types that can be created as spot instances, the policy prioritizes these spot instances. If launching spot instances fails for reasons such as insufficient inventory, the policy automatically attempts to create pay-as-you-go instances. During a scale-in, the instance with the highest vCPU unit price is removed first.

  • Custom Combination Policy

    This policy gives you fine-grained control over your capacity distribution. You can use it to adjust the ratio of pay-as-you-go to spot instances, balance capacity across zones, and define the instance type selection strategy.

For configuration instructions, see Configure a scaling policy.

Configure a scaling policy

Existing scaling group

To modify the Scaling Policy of an existing scaling group, follow these steps.

  1. Log on to the Auto Scaling console.

  2. In the left-side navigation pane, click Scaling Groups.

  3. In the top navigation bar, select the region where Auto Scaling is activated.

  4. On the Scaling Groups page, find the scaling group whose Scaling Policy you want to modify and click Edit in the Actions column to open the Edit Scaling Group window.

  5. Set the Scaling Policy.

    If you select the Distribution Balancing, Cost Optimization, or Custom Combination Policy, you must also configure the sub-settings. For more information, see Sub-settings.

  6. Click OK.

New scaling group

You can configure the Scaling Policy when you create a scaling group on the console, as the following figure shows.

image

If you select the Cost Optimization or Custom Combination Policy, you must also configure the sub-settings. For more information, see Sub-settings.

Parameters

If you select the Distribution Balancing, Cost Optimization, or Custom Combination Policy, see the following tables for configuration details.

Balanced distribution policy

Parameter

Description

Balanced Mode

  • Best-effort delivery mode: The default delivery mode. If an instance cannot be created in an availability zone due to resource constraints, the scaling group falls back to other availability zones.

  • Balance only: If an instance cannot be created in an availability zone due to resource constraints, the scaling group does not fall back to other availability zones.

Enable Auto-rebalance

If enabled, the scaling group automatically monitors capacity across availability zones. If the instance distribution becomes unbalanced, the scaling group automatically starts a scaling activity to rebalance the instances.

Cost optimization policy

Parameter

Description

Minimum Number of Pay-as-you-go Instances

The minimum number of pay-as-you-go ECS instances to maintain in the scaling group. The default is 0. If the number of pay-as-you-go instances in the group falls below this value, the scaling group prioritizes creating pay-as-you-go instances during scale-out events.

Percentage of Pay-as-you-go Instances

The percentage of pay-as-you-go instances among automatically created ECS instances is 70% by default. This calculation does not include the minimum number of pay-as-you-go instances in the group.

Lowest Cost Instance Types

Specifies the number of lowest-priced instance types to use. The default is 1. This parameter applies only if you specify multiple instance types in the scaling configuration. When creating preemptible instances, the scaling group distributes new instances evenly across this number of lowest-priced instance types.

Enable Supplemental Spot Instances

If enabled, the scaling group automatically replaces a preemptible instance approximately 5 minutes before it is reclaimed.

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

Enabled by default. If the required preemptible instance capacity is unavailable due to price or stock, the scaling group attempts to create pay-as-you-go instances to meet the demand.

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

When Use Pay-as-you-go Instances to Supplement Spot Capacity is enabled, the proportion of pay-as-you-go instances in the group may exceed the specified Percentage of Pay-as-you-go Instances. If you enable this option, the scaling group attempts to replace pay-as-you-go instances with preemptible instances to maintain the desired ratio.

Custom combination policy

Parameter

Description

Minimum Number of Pay-as-you-go Instances

The minimum number of pay-as-you-go ECS instances to maintain in the scaling group. The default is 0. If the number of pay-as-you-go instances in the group falls below this value, the scaling group prioritizes creating pay-as-you-go instances during scale-out events.

Percentage of Pay-as-you-go Instances

The percentage of pay-as-you-go instances among automatically created ECS instances is 70% by default. The number of instances that corresponds to the minimum number of pay-as-you-go instances in the group is excluded from this calculation.

Multi-zone Balanced Distribution

Distributes ECS instances evenly across the multiple availability zones specified for the scaling group (via multiple vSwitches).

Note

You can also manually trigger a rebalance to redistribute ECS instances across availability zones. For more information, see Rebalance ECS instances.

Capacity Planning Policy

Determines how the scaling group selects available instance types to fulfill capacity requirements.

  • Instance Type Configuration Order: Launches instances according to the order of instance types specified in the scaling configuration.

  • Lowest Price: Launches instances based on the price per vCPU for each instance type, from lowest to highest.

Configure Spot Capacity Planning Policy

If enabled, you can specify a separate capacity distribution policy for preemptible instances.

Spot Capacity Planning Policy

Same as Capacity Planning Policy.

Lowest Cost Instance Types

Specifies the number of lowest-priced instance types to use. The default is 1. This parameter applies only if you specify multiple instance types in the scaling configuration. When creating preemptible instances, the scaling group distributes new instances evenly across this number of lowest-priced instance types.

Enable Supplemental Spot Instances

If enabled, the scaling group automatically replaces a preemptible instance approximately 5 minutes before it is reclaimed.

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

Enabled by default. If the required preemptible instance capacity is unavailable due to price or stock, the scaling group attempts to create pay-as-you-go instances to meet the demand.

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

When Use Pay-as-you-go Instances to Supplement Spot Capacity is enabled, the proportion of pay-as-you-go instances in the group may exceed the specified Percentage of Pay-as-you-go Instances. If you enable this option, the scaling group attempts to replace pay-as-you-go instances with preemptible instances to maintain the desired ratio.

Modify a scaling policy by API

Call the ModifyScalingGroup API operation to modify a scaling group's scaling policy. The required parameters depend on the chosen policy, as described in the following sections.

Priority policy

This policy scales out instances based on the priority of the vSwitches that you define. If an instance cannot be created in a higher-priority zone, Auto Scaling automatically tries to create it in the zone with the next-highest priority.

Parameter

Type

Description

Configuration

ScalingGroupId

string

The ID of the scaling group. (Required)

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

MultiAZPolicy

string

The multi-zone scaling policy. (Required)

To implement the Priority, set this parameter to PRIORITY.

Balanced distribution policy

Important

To create instances across multiple zones, the scaling group must be configured with vSwitches in those zones.

Parameter

Type

Description

Configuration

ScalingGroupId

string

The ID of the scaling group. (Required)

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

MultiAZPolicy

string

The multi-zone scaling policy. (Required)

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

BalanceMode

string

Optional. The balancing mode.

Valid values:

  • BalancedBestEffort: In Best-effort Delivery, if an instance cannot be created in a zone due to resource limitations, Auto Scaling tries to create the instance in another zone to meet the required capacity.

  • BalancedOnly: If an instance cannot be created in a zone due to resource limitations, Auto Scaling does not attempt to create it in another zone.

Default value: BalancedBestEffort

AutoRebalance

boolean

Optional. Specifies whether to enable automatic zone rebalancing.

If enabled, the scaling group automatically monitors capacity across zones. If capacity becomes unbalanced, the group proactively rebalances instances across the zones.

This setting applies only when BalanceMode=BalancedOnly.

Valid values:

  • false: The feature is disabled.

  • true: The feature is enabled.

Default value: false.

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

Cost optimization policy

This policy creates instances based on the lowest vCPU unit price. If the scaling configuration includes spot instances, Auto Scaling creates spot instances first. If spot instances cannot be created, Auto Scaling attempts to create pay-as-you-go instances.

Important

The cost optimization policy takes effect only if the scaling configuration is configured with multiple instance types or has spot instances enabled.

Parameter

Type

Description

Configuration

ScalingGroupId

string

The ID of the scaling group. (Required)

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

MultiAZPolicy

string

The multi-zone scaling policy. (Required)

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

OnDemandBaseCapacity

integer

Optional. The minimum number of pay-as-you-go instances in the scaling group.

If the number of pay-as-you-go instances in the scaling group is less than this value, Auto Scaling creates pay-as-you-go instances first.

Configure as required.

Valid values: 0 to 1,000.

Default value: 0.

OnDemandPercentageAboveBaseCapacity

integer

Optional. The percentage of pay-as-you-go instances among the instances that are created in excess of the base capacity.

The proportion of pay-as-you-go instances among excess instances after the OnDemandBaseCapacity is met.

Configure as required.

Valid values: 0 to 100.

Default value: 0.

SpotInstancePools

integer

The number of lowest-priced instance types to use.

This parameter takes effect only when multiple instance types are specified in the scaling configuration.
When creating spot instances, the scaling group distributes ECS instances across the specified number of lowest-priced instance types.

Configure as required.

Valid values: 0 to 10.

Default value: 2.

SpotInstanceRemedy

boolean

Specifies whether to enable spot instance remedy.

If you enable spot instance remedy, Auto Scaling proactively creates a new spot instance to replace a spot instance that is about to be reclaimed. The replacement is created approximately 5 minutes before the instance is reclaimed.

Configure as required.

Valid values:

  • true: The feature is enabled.

  • false: The feature is disabled.

CompensateWithOnDemand

boolean

Specifies whether to compensate with pay-as-you-go instances.

If sufficient spot instances cannot be created due to price or inventory issues, this parameter specifies whether to allow Auto Scaling to create pay-as-you-go instances to meet the capacity requirement.

Configure as required.

Valid values:

  • true: The feature is enabled.

  • false: The feature is disabled.

CapacityOptions.SpotAutoReplaceOnDemand

boolean

Specifies whether to automatically replace pay-as-you-go instances with spot instances.

When CompensateWithOnDemand is enabled, if the proportion of pay-as-you-go instances exceeds the value of OnDemandPercentageAboveBaseCapacity, it attempts to use spot instances to replace pay-as-you-go capacity.

Configure as required.

Valid values:

  • true: The feature is enabled.

  • false: The feature is disabled.

Custom combination policy

This policy lets you adjust the ratio of pay-as-you-go instances to spot instances in a scaling group, balance capacity across zones, and define the instance type selection strategy.

Parameter

Type

Description

Configuration

ScalingGroupId

string

The ID of the scaling group. (Required)

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

MultiAZPolicy

string

The multi-zone scaling policy. (Required)

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

OnDemandBaseCapacity

integer

Optional. The minimum number of pay-as-you-go instances in the scaling group.

If the number of pay-as-you-go instances in the scaling group is less than this value, Auto Scaling creates pay-as-you-go instances first.

Configure as required.

Valid values: 0 to 1,000.

Default value: 0.

OnDemandPercentageAboveBaseCapacity

integer

Optional. The percentage of pay-as-you-go instances among the instances that are created in excess of the base capacity.

The proportion of pay-as-you-go instances among instances launched in excess of the OnDemandBaseCapacity.

Configure as required.

Valid values: 0 to 100.

Default value: 100.

AzBalance

boolean

Optional. Specifies whether to enable capacity balancing across zones.

This feature evenly distributes ECS instances across the multiple zones (specified by multiple vSwitches) of the scaling group. If the instance distribution becomes unbalanced due to reasons such as insufficient inventory, you can call the RebalanceInstances API operation to rebalance the instances. For more information, see RebalanceInstances.

Configure as required.

Valid values:

  • true: The feature is enabled.

  • false: The feature is disabled.

AllocationStrategy

string

Optional. The allocation strategy for selecting instance types.

The allocation strategy determines how the scaling group selects from available instance types to fulfill capacity requirements.

Configure as required.

Valid values:

  • priority (default): Creates instances by following the order of instance types specified in the scaling configuration.

  • lowestPrice: Creates instances from the instance types with the lowest vCPU unit price.

SpotAllocationStrategy

string

Optional. The allocation strategy for spot instances.

You can use this parameter to specify a separate allocation strategy for spot capacity.

Configure as required.

Valid values:

  • priority: Creates instances by following the order of instance types specified in the scaling configuration.

  • lowestPrice: Creates instances from the instance types with the lowest vCPU unit price.

SpotInstancePools

integer

The number of lowest-priced instance types to use.

Important

This parameter is required when AllocationStrategy or SpotAllocationStrategy is set to lowestPrice.

This parameter takes effect only when multiple instance types are specified in the scaling configuration.
When creating spot instances, the scaling group distributes ECS instances across the specified number of lowest-priced instance types.

Configure as required.

Valid values: 0 to 10.

Default value: 2.

SpotInstanceRemedy

boolean

Specifies whether to enable spot instance remedy.

Important

This parameter is required when AllocationStrategy or SpotAllocationStrategy is set to lowestPrice.

If you enable spot instance remedy, Auto Scaling proactively creates a new spot instance to replace a spot instance that is about to be reclaimed. The replacement is created approximately 5 minutes before the instance is reclaimed.

Configure as required.

Valid values:

  • true: The feature is enabled.

  • false: The feature is disabled.

CompensateWithOnDemand

boolean

Specifies whether to compensate with pay-as-you-go instances.

Important

This parameter is required when AllocationStrategy or SpotAllocationStrategy is set to lowestPrice.

If sufficient spot instances cannot be created due to price or inventory issues, this parameter specifies whether to allow Auto Scaling to create pay-as-you-go instances to meet the capacity requirement.

Configure as required.

Valid values:

  • true: The feature is enabled.

  • false: The feature is disabled.

CapacityOptions.SpotAutoReplaceOnDemand

boolean

Specifies whether to automatically replace pay-as-you-go instances with spot instances.

When CompensateWithOnDemand is enabled, if the on-demand percentage exceeds the OnDemandPercentageAboveBaseCapacity percentage, the system will attempt to use Spot Instances to replace on-demand capacity.

Configure as required.

Valid values:

  • true: The feature is enabled.

  • false: The feature is disabled.