All Products
Search
Document Center

Auto Scaling:ModifyScalingGroup

Last Updated:Apr 10, 2024

Modifies a scaling group. When your scaling group cannot meet your business requirements, you can call the ModifyScalingGroup operation to modify the scaling group attributes such as the maximum, minimum, and expected numbers of instances. This prevents repeated creation and configuration of scaling groups, which saves you a lot of time and resource costs.

Usage notes

  • You cannot modify the following parameters:

    • RegionId

    • LoadBalancerId

      Note

      If you want to adjust the load balancers attached to your scaling group, you can call the AttachLoadBalancers operation or the DetachLoadBalancers operation.

    • DBInstanceId

      Note

      If you want to adjust the ApsaraDB RDS instances attached to your scaling group, you can call the AttachDBInstances operation or the DetachDBInstances operation.

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

  • The enablement of a new scaling configuration in the desired scaling group does not affect the Elastic Compute Service (ECS) instances that are created from the previous scaling configuration and running as expected.

  • If the modification of MaxSize causes the total number of ECS instances in the scaling group to exceed the value of MaxSize, Auto Scaling automatically removes the extra ECS instances from the scaling group to ensure that the total number is equal to the value of MaxSize.

  • If the modification of MinSize causes the total number of ECS instances in the scaling group to drop 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 the modification of DesiredCapacity caused the total number of ECS instances in the scaling group not to match the value of DesiredCapacity, Auto Scaling automatically adds ECS instances to or removes ECS instances 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 that must be contained in the scaling group. When the number of ECS instances in the scaling group is less than the value of MinSize, Auto Scaling automatically adds ECS 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 that can be contained in the scaling group. When the number of ECS instances in the scaling group is greater than the value of MaxSize, Auto Scaling automatically removes ECS 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 valid values of MaxSize range 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 the scaling activities triggered by CloudMonitor event-triggered tasks.

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 based on 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 based on 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 based on 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 check the health status of instances in the scaling group.

ECS: Auto Scaling checks the health status of ECS instances in the scaling group.

LOAD_BALANCER: Auto Scaling checks the health status of instances in the scaling group 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.

Note

HealthCheckType has the same effect as HealthCheckTypes. You can select one of them to specify based on your business requirements. If you specify HealthCheckTypes, HealthCheckType is ignored. HealthCheckType is optional.

LaunchTemplateId

String

No

lt-m5e3ofjr1zn1aw7****

The ID of the launch template that provides instance configurations for 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 template version.

  • Latest: the latest template version.

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 preferentially creates pay-as-you-go instances.

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

OnDemandPercentageAboveBaseCapacity

Integer

No

20

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

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

SpotInstanceRemedy

Boolean

No

true

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

CompensateWithOnDemand

Boolean

No

true

Specifies whether to automatically create pay-as-you-go instances to meet the requirements on the number of ECS instances in the scaling group when the 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 in the CreateScalingGroup operation to COST_OPTIMIZED. Valid values:

  • true

  • false

SpotInstancePools

Integer

No

5

The number of instance types that you specify. 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:

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

DesiredCapacity

Integer

No

5

The expected number of ECS 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 re-enable the Expected Number of Instances feature for a scaling group, you must set a new value for DesiredCapacity.

GroupDeletionProtection

Boolean

No

true

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

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

  • false: disables Deletion Protection for the scaling group.

MultiAZPolicy

String

No

PRIORITY

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

  • PRIORITY: ECS instances are scaled based on the vSwitch priority. The first vSwitch specified by VSwitchIds has the highest priority. Auto Scaling preferentially scales instances in the zone where the vSwitch of the highest priority resides. If the scaling fails, Auto Scaling scales instances in the zone where the vSwitch of the next highest priority resides.

  • COST_OPTIMIZED: Auto Scaling creates ECS instances whose vCPUs are provided at the lowest price during scale-outs and removes ECS instances whose vCPUs are provided at the highest price during scale-ins. 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

    The COST_OPTIMIZED setting takes effect only when you specify multiple instance types or when you specify at least one preemptible instance type.

  • BALANCE: ECS instances are evenly distributed 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 balance the distribution of the 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. 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 of the highest priority resides, Auto Scaling creates ECS instances in the zone where the vSwitch of the next highest priority resides.

LaunchTemplateOverride.N.InstanceType

String

No

ecs.c5.xlarge

Instance type N. The instance type that is specified by using this parameter overrides 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.InstanceType and LaunchTemplateOverride.N.WeightedCapacity at the same time.

You can specify N instance types by using the Extend Instance Type of 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 meet the expected capacity requirement.

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 capacity: 6

  • Capacity of ecs.c5.xlarge: 4

To meet the expected capacity requirement, Auto Scaling must create two ecs.c5.xlarge instances.

Note

The capacity of the scaling group during a scale-out cannot exceed the sum of the maximum number of instances that is specified by MaxSize and the maximum weight of the instance types.

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 N instance types by using the Extend Instance Type of 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 the allocation policy to create instances. The policy can be applied 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 the specified order of the instance types to create the required number of instances.

  • lowestPrice: Auto Scaling selects instance types that have the lowest unit price of vCPU 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 individually 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 the specified order of the instance types to create the required number of preemptible instances.

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

Default value: priority.

MaxInstanceLifetime

Integer

No

null

The maximum life span of an ECS 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 takes effect only if you specify CustomPolicy as the value of RemovalPolicy.1.

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 when 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 reclaim mode of the scaling group. Valid values:

  • recycle: economical mode

  • release: release mode

  • forcerelease: forced release mode

    Note

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

  • forcerecycle: 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-ins. Forced shutdown is equivalent to power outage. Forced shutdown 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 ECS 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 check the health status of instances in the scaling group.

  • ECS: Auto Scaling checks the health status of ECS instances in the scaling group.

  • LOAD_BALANCER: Auto Scaling checks the health status of ECS instances in the scaling group 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.

Note

HealthCheckTypes has the same effect as HealthCheckType. You can select one of them to specify based on your business requirements. If you specify HealthCheckType, HealthCheckTypes is ignored. HealthCheckTypes is optional.

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 the 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 that 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 that 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 that 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 in the launch template contains non-digit characters.