All Products
Search
Document Center

Auto Scaling:ModifyScalingGroup

Last Updated:Oct 30, 2024

Modifies a scaling group. If you want to enable policy-based automatic addition or removal of instances of a specific type to meet evolving business requirements, you can modify scaling groups to adjust your computing power with ease. Computing power refers to the instances that provide the computing capability. If your scaling group no longer meets your business requirements, you can call the ModifyScalingGroup operation to modify attributes such as the maximum, minimum, and expected numbers of instances. This prevents the need to repeatedly create and configure scaling groups, which saves significant time and resources.

Usage notes

  • You cannot call this operation to modify the settings of the following parameters:

  • You can call this operation only if the desired scaling group is in the Active or Inactive state.

  • If you enable a new scaling configuration in the desired scaling group, the running of Elastic Compute Service (ECS) instances or elastic container instances created from the previous scaling configuration remains unaffected.

  • If you modify MaxSize and the total number of ECS instances or elastic container instances in the scaling group exceeds the value of MaxSize, Auto Scaling automatically removes the excess instances from the scaling group to ensure that the total number is equal to the value of MaxSize.

  • If you modify MinSize and the total number of ECS instances or elastic container instances in the scaling group drops below the value of MinSize, Auto Scaling automatically adds ECS instances to the scaling group to ensure that the total number is equal to the value of MinSize.

  • If you modify DesiredCapacity and the total number of ECS instances or elastic container instances in the scaling group does not match the value of DesiredCapacity, Auto Scaling automatically adds or removes instances to or from the scaling group to ensure that the total number is equal to the value of DesiredCapacity.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter

Type

Required

Example

Description

Action

String

Yes

ModifyScalingGroup

The operation that you want to perform. Set the value to ModifyScalingGroup.

ScalingGroupId

String

Yes

asg-bp1ffogfdauy0jw0****

The ID of the scaling group that you want to modify.

ScalingGroupName

String

No

scalinggroup****

The name of the scaling group. The name of a scaling group must be unique in a region. The name must be 2 to 64 characters in length, and can contain letters, digits, underscores (_), hyphens (-), and periods (.). The name must start with a letter or a digit.

MinSize

Integer

No

1

The minimum number of ECS instances or elastic container instances that must be contained in the scaling group. If the number of instances in the scaling group is less than the value of MinSize, Auto Scaling automatically adds instances to the scaling group until the number of instances is equal to the value of MinSize.

Note

The value of MinSize must be less than or equal to the value of MaxSize.

MaxSize

Integer

No

99

The maximum number of ECS instances or elastic container instances that can be contained in the scaling group. If the number of instances in the scaling group is greater than the value of MaxSize, Auto Scaling automatically removes instances from the scaling group until the number of instances is equal to the value of MaxSize.

The value range of MaxSize varies based on the instance quota. You can go to Quota Center to check the quota of instances that can be added to a scaling group.

For example, if the quota of instances that can be added to a scaling group is 2,000, the value range of MaxSize is from 0 to 2000.

DefaultCooldown

Integer

No

600

The cooldown period of the scaling group after a scaling activity is complete. Valid values: 0 to 86400. Unit: seconds.

During the cooldown period, Auto Scaling does not execute scaling activities that are triggered by CloudMonitor event-triggered tasks in the scaling group.

RemovalPolicy.1

String

No

OldestScalingConfiguration

The first step of the instance removal policy. Valid values:

  • OldestInstance: removes ECS instances that are added at the earliest point in time to the scaling group.

  • NewestInstance: removes ECS instances that are most recently added to the scaling group.

  • OldestScalingConfiguration: removes ECS instances that are created from the earliest scaling configuration.

  • CustomPolicy: removes ECS instances based on the custom scale-in policy (Function).

Note

The scaling configuration source specified by OldestScalingConfiguration can be a scaling configuration or a launch template. The CustomPolicy setting is available only for RemovalPolicy.1. If you set RemovalPolicy.1 to CustomPolicy, you must specify CustomPolicyARN.

RemovalPolicy.2

String

No

NewestInstance

The second step of the instance removal policy. Valid values:

  • OldestInstance: removes ECS instances that are added at the earliest point in time to the scaling group.

  • NewestInstance: removes ECS instances that are most recently added to the scaling group.

  • OldestScalingConfiguration: removes ECS instances that are created from the earliest scaling configuration.

    Note

    The scaling configuration source specified by OldestScalingConfiguration can be a scaling configuration or a launch template.

RemovalPolicy.3

String

No

OldestInstance

The third step of the instance removal policy. Valid values:

  • OldestInstance: removes ECS instances that are added at the earliest point in time to the scaling group.

  • NewestInstance: removes ECS instances that are most recently added to the scaling group.

  • OldestScalingConfiguration: removes ECS instances that are created from the earliest scaling configuration.

Note

The scaling configuration source specified by OldestScalingConfiguration can be a scaling configuration or a launch template.

ActiveScalingConfigurationId

String

No

asc-bp17pelvl720x5ub****

The ID of the active scaling configuration in the scaling group.

HealthCheckType

String

No

ECS

The health check mode of the scaling group. Valid values:

  • NONE: Auto Scaling does not perform health checks on instances in the scaling group.

  • ECS: Auto Scaling performs health checks on instances in the scaling group. If you want to enable instance health check, set the value to ECS, regardless of whether the scaling group is of the ECS or Elastic Container Instance type.

  • LOAD_BALANCER: Auto Scaling performs health checks on instances based on the health check results of load balancers. The health check results of Classic Load Balancer (CLB) instances are not supported as the health check basis for instances in the scaling group.

Default value: ECS.

Note

If you want to enable instance health check and load balancer health check at the same time, specify HealthCheckTypes.

LaunchTemplateId

String

No

lt-m5e3ofjr1zn1aw7****

The ID of the launch template that is used by Auto Scaling to create instances.

LaunchTemplateVersion

String

No

Default

The version number of the launch template. Valid values:

  • A fixed template version number.

  • Default: the default version of the template.

  • Latest: the latest version of the template.

OnDemandBaseCapacity

Integer

No

30

The minimum number of pay-as-you-go instances that must be contained in the scaling group. Valid values: 0 to 1000. If the number of pay-as-you-go instances is less than the value of this parameter, Auto Scaling creates pay-as-you-go instances.

If you set MultiAZPolicy to COMPOSABLE, the default value is 0.

OnDemandPercentageAboveBaseCapacity

Integer

No

20

The percentage of pay-as-you-go instances among the excess instances when the minimum number of pay-as-you-go instances is reached. Valid values: 0 to 100.

If you set MultiAZPolicy to COMPOSABLE, the default value is 100.

SpotInstanceRemedy

Boolean

No

true

Specifies whether to enable the supplementation of preemptible instances. If you set this parameter to true, Auto Scaling creates an instance to replace a preemptible instance when Auto Scaling receives the system message that the preemptible instance is to be reclaimed.

CompensateWithOnDemand

Boolean

No

true

Specifies whether to automatically create pay-as-you-go instances to reach the minimum number of ECS instances in the scaling group when the required number of preemptible instances cannot be reached due to reasons such as cost-related issues and insufficient resources. This parameter takes effect only if you set MultiAZPolicy to COST_OPTIMIZED in the CreateScalingGroup operation. Valid values:

  • true

  • false

SpotInstancePools

Integer

No

5

The number of instance types. Auto Scaling evenly creates preemptible instances of multiple instance types that are provided at the lowest cost across the zones of the scaling group. Valid values: 0 to 10.

If you set MultiAZPolicy to COMPOSABLE, the default value is 2.

DesiredCapacity

Integer

No

5

The expected number of ECS instances or elastic container instances in the scaling group. If you specify this parameter, the Expected Number of Instances feature is enabled. In this case, Auto Scaling maintains the number of instances in the scaling group at the expected number. The expected number cannot be greater than the value of MaxSize and cannot be less than the value of MinSize.

Note

If you want to enable the Expected Number of Instances feature after you disable it, you must respecify DesiredCapacity.

GroupDeletionProtection

Boolean

No

true

Specifies whether to enable the Deletion Protection feature for the scaling group. Valid values:

  • true: enables the Deletion Protection feature for the scaling group. The scaling group cannot be deleted.

  • false: disables the Deletion Protection feature for the scaling group.

MultiAZPolicy

String

No

PRIORITY

The scaling policy of the multi-zone scaling group of the ECS type. Valid values:

  • PRIORITY: Auto Scaling scales ECS instances based on the vSwitch priority. The first vSwitch specified by VSwitchIds.N has the highest priority. Auto Scaling preferentially scales instances in the zone where the vSwitch that has the highest priority resides. If the scaling fails, Auto Scaling attempts to scale instances in the zone where the vSwitch that has the next highest priority resides.

  • COST_OPTIMIZED: Auto Scaling preferentially scales out ECS instances whose vCPUs are provided at the lowest price and scales in ECS instances whose vCPUs are provided at the highest price. If preemptible instance types are specified in the active scaling configuration, Auto Scaling preferentially creates preemptible instances. You can use CompensateWithOnDemand to specify whether to automatically create pay-as-you-go instances when Auto Scaling fails to create preemptible instances.

    Note

    COST_OPTIMIZED is valid if you specify multiple instance types or at least one preemptible instance type.

  • BALANCE: Auto Scaling evenly distributes ECS instances across the zones that are specified for the scaling group. If ECS instances are unevenly distributed across the zones due to insufficient resources, you can call the RebalanceInstance operation to rebalance the distribution of the ECS instances.

  • COMPOSABLE: You can flexibly combine the preceding policies based on your business requirements.

VSwitchIds.N

String

No

vsw-bp1oo2a7isyrb8igf****

The ID of vSwitch N. Valid values of N: 1 to 5.

This parameter takes effect only if the network type of the scaling group is virtual private cloud (VPC). The specified vSwitches and the scaling group must be in the same VPC.

The vSwitches can reside in different zones. The vSwitches are sorted in ascending order based on the value of N. A value of 1 specifies the highest priority. A greater value of N specifies a lower priority. If Auto Scaling fails to create ECS instances in the zone where the vSwitch that has the highest priority resides, Auto Scaling creates ECS instances in the zone where the vSwitch that has the next highest priority resides.

LaunchTemplateOverride.N.InstanceType

String

No

ecs.c5.xlarge

Instance type N. The instance type that is specified by this parameter overwrites the instance type that is specified in the launch template. If you want to scale instances in the scaling group based on the weighted capacity of instances, you must specify LaunchTemplateOverride.N.WeightedCapacity after you specify this parameter.

You can specify multiple instance types by using the Extend Launch Template feature. Valid values of N: 1 to 10.

Note

This parameter takes effect only if you specify LaunchTemplateId.

For information about the valid values of InstanceType in InstanceTypeOverride.N.InstanceType, see Overview of instance families.

LaunchTemplateOverride.N.WeightedCapacity

Integer

No

4

The weight of instance type N. The weight of an instance type specifies the capacity of a single instance of the instance type in the scaling group. If you want to scale instances in the scaling group based on the weighted capacity of instances, you must specify LaunchTemplateOverride.N.WeightedCapacity after you specify LaunchTemplateOverride.N.InstanceType. The values of N in the two parameters must be the same.

A higher weight specifies that a smaller number of instances of instance type N are required to achieve the expected capacity.

Performance metrics, such as the number of vCPUs and the memory size of each instance type, may vary. You can specify different weights for different instance types based on your business requirements.

Example:

  • Current capacity: 0.

  • Expected number: 6.

  • Capacity of ecs.c5.xlarge: 4.

To achieve the expected capacity, Auto Scaling must scale out two ecs.c5.xlarge instances.

Note

The total capacity of the scaling group is limited and cannot exceed the sum of the maximum group size specified by MaxSize and the highest weight assigned to an instance type.

Valid values of WeightedCapacity in InstanceTypeOverride.N.WeightedCapacity: 1 to 500.

LaunchTemplateOverride.N.SpotPriceLimit

Float

No

0.025

The maximum bid price of instance type N that is specified by LaunchTemplateOverride.N.InstanceType. You can specify multiple instance types by using the Extend Launch Template feature. Valid values of N: 1 to 10.

Note

This parameter takes effect only if you specify LaunchTemplateId.

AzBalance

Boolean

No

false

Specifies whether to evenly distribute instances in the scaling group across multiple zones. This parameter takes effect only if you set MultiAZPolicy to COMPOSABLE. Valid values:

  • true

  • false

Default value: false.

AllocationStrategy

String

No

priority

The allocation policy of instances. Auto Scaling selects instance types based on this policy to create the required number of instances. The policy applies to pay-as-you-go instances and preemptible instances. This parameter takes effect only if you set MultiAZPolicy to COMPOSABLE. Valid values:

  • priority: Auto Scaling selects instance types based on their specified order to create the required number of instances.

  • lowestPrice: Auto Scaling selects instance types that have the lowest unit price of vCPUs to create the required number of instances.

Default value: priority.

SpotAllocationStrategy

String

No

lowestPrice

The allocation policy of preemptible instances. You can use this parameter to specify the allocation policy for preemptible instances. This parameter takes effect only if you set MultiAZPolicy to COMPOSABLE. Valid values:

  • priority: Auto Scaling selects instance types based on their specified order to create the required number of preemptible instances.

  • lowestPrice: Auto Scaling selects instance types that have the lowest unit price of vCPUs to create the required number of preemptible instances.

Default value: priority.

MaxInstanceLifetime

Integer

No

null

The maximum life span of each instance in the scaling group. Unit: seconds.

Valid values: 86400 to Integer.maxValue. You can also set this parameter to 0. A value of 0 specifies that the instance has an unlimited life span in the scaling group.

Default value: null.

Note

This parameter is unavailable for scaling groups of the Elastic Container Instance type or scaling groups whose ScalingPolicy is set to recycle.

CustomPolicyARN

String

No

acs:fc:cn-zhangjiakou:16145688****:services/ess_custom_terminate_policy.LATEST/functions/ess_custom_terminate_policy_name

The Alibaba Cloud Resource Name (ARN) of the custom scale-in policy (Function). This parameter is available only if you specify CustomPolicy as the first step of the instance removal policy.

DisableDesiredCapacity

Boolean

No

false

Specifies whether to disable the Expected Number of Instances feature for the scaling group. Valid values:

  • false

  • true

    Note

    You can set this parameter to true only if the scaling group has no ongoing scaling activities. If you set this parameter to true, the value of DesiredCapacity parameter is cleared but the number of existing instances in the scaling group remains unchanged.

ScalingPolicy

String

No

recycle

The instance reclaim mode of the scaling group. Valid values:

  • recycle: the economical mode.

  • release: the release mode.

  • forcerelease: the forced release mode.

    Note

    If you set this parameter to forcerelease, Auto Scaling forcibly releases instances that are in the Running state during scale-in events. Forced release is equivalent to a power outage and may cause ephemeral data on instances to be cleared beyond recovery. Exercise caution when you specify this setting.

  • forcerecycle: the forced recycle mode.

    Note

    If you set this parameter to forcerecycle, Auto Scaling forcibly shuts down instances that are in the Running state during scale-in events. Forced shutdown is equivalent to a power outage and may cause ephemeral data on instances to be cleared beyond recovery. Exercise caution when you specify this setting.

ScalingPolicy specifies the reclaim mode of scaling groups. The policy that is used to remove instances from scaling groups is specified by RemovePolicy of the RemoveInstances operation. For more information, see RemoveInstances.

HealthCheckTypes.N

String

No

ECS

The health check modes of the scaling group. Valid values:

  • NONE: Auto Scaling does not perform health checks on instances in the scaling group.

  • ECS: Auto Scaling performs health checks on instances in the scaling group. If you want to enable instance health check, set the value to ECS, regardless of whether the scaling group is of the ECS or Elastic Container Instance type.

  • LOAD_BALANCER: Auto Scaling performs health checks on instances based on the health check results of load balancers. The health check results of CLB instances are not supported as the health check basis for instances in the scaling group.

Default value: ECS.

StopInstanceTimeout

Integer

No

60

The period of time that is required by ECS instances to enter the Stopped state during the scale-in process. Unit: seconds.

Valid values: 30 to 240.

Note
  • This parameter takes effect only if you set ScalingPolicy to release.

  • If you specify this parameter, the system proceeds with the scale-in process only after the period of time specified by StopInstanceTimeout ends. In this case, the scale-in operation continues regardless of whether or not the ECS instances enter the Stopped state.

  • If you do not specify this parameter, the system proceeds with the scale-in process only after the ECS instances enter the Stopped state. If the ECS instances fail to enter the Stopped state, the scale-in process rolls back, and the scale-in operation fails.

  • If you set the value to 0, this parameter is ignored.

Response parameters

Parameter

Type

Example

Description

RequestId

String

473469C7-AA6F-4DC5-B3DB-A3DC0DE3****

The request ID.

Examples

Sample requests

http(s)://ess.aliyuncs.com/?Action=ModifyScalingGroup
&ScalingGroupId=asg-bp1ffogfdauy0jw0****
&ScalingGroupName=scalinggroup****
&MinSize=1
&MaxSize=99
&DefaultCooldown=600
&RemovalPolicy.1=OldestScalingConfiguration
&RemovalPolicy.2=NewestInstance
&RemovalPolicy.3=OldestInstance
&ActiveScalingConfigurationId=asc-bp17pelvl720x5ub****
&HealthCheckType=ECS
&LaunchTemplateId=lt-m5e3ofjr1zn1aw7****
&LaunchTemplateVersion=Default
&OnDemandBaseCapacity=30
&OnDemandPercentageAboveBaseCapacity=20
&SpotInstanceRemedy=true
&CompensateWithOnDemand=true
&SpotInstancePools=5
&DesiredCapacity=5
&GroupDeletionProtection=true
&MultiAZPolicy=PRIORITY
&VSwitchIds=["vsw-bp1oo2a7isyrb8igf****"]
&LaunchTemplateOverride=[{"InstanceType":"ecs.c5.xlarge","WeightedCapacity":4,"SpotPriceLimit":0.025}]
&AzBalance=false
&AllocationStrategy=priority
&SpotAllocationStrategy=lowestPrice
&CustomPolicyARN=acs:fc:cn-zhangjiakou:16145688****:services/ess_custom_terminate_policy.LATEST/functions/ess_custom_terminate_policy_name
&DisableDesiredCapacity=false
&ScalingPolicy=recycle
&HealthCheckTypes=["ECS"]
&<Common request parameters>

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<ModifyScalingGroupResponse>
    <RequestId>473469C7-AA6F-4DC5-B3DB-A3DC0DE3****</RequestId>
</ModifyScalingGroupResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "RequestId" : "473469C7-AA6F-4DC5-B3DB-A3DC0DE3****"
}

Error codes

For a list of error codes, see Service error codes.

HTTP status code

Error code

Error message

Description

404

InvalidScalingGroupId.NotFound

The specified scaling group does not exist.

The specified scaling group does not exist within your Alibaba Cloud account.

400

InvalidScalingGroupName.Duplicate

The specified value of parameter

parameter name

is duplicated.

The name that you specified for the scaling group is already used by an existing scaling group.

404

InvalidScalingConfigurationId.NotFound

The specified scaling configuration does not exist.

The specified scaling configuration does not exist in the scaling group.

400

InvalidScalingConfigurationId.InstanceTypeMismatch

The specified scaling configuration and existing active scaling configuration have different instance type.

The instance type in the specified scaling configuration is different from the instance type in the active scaling configuration.

400

InvalidParameter.Conflict

The value of parameter

parameter name

and parameter

parameter name

are confilict.

The value of MinSize is greater than the value of MaxSize.

400

LaunchTemplateVersionSet.NotFound

The specific version of launch template is not exist.

The version of the launch template does not exist.

400

LaunchTemplateSet.NotFound

The specified launch template set is not found.

The launch template does not exist.

400

TemplateMissingParameter.ImageId

The input parameter "ImageId" that is mandatory for processing this request is not supplied.

No value is specified for ImageId, which is required in the launch template.

400

TemplateMissingParameter.InstanceTypes

The input parameter "InstanceTypes" that is mandatory for processing this request is not supplied.

No value is specified for InstanceTypes, which is required in the launch template.

400

TemplateMissingParameter.SecurityGroup

The input parameter "SecurityGroup" that is mandatory for processing this request is not supplied.

No value is specified for SecurityGroup, which is required in the launch template.

400

TemplateVersion.NotNumber

The input parameter "LaunchTemplateVersion" is supposed to be a string representing the version number.

The fixed version number that is specified for LaunchTemplateVersion of the launch template contains non-digit characters.