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:
RegionId
LoadBalancerId
NoteIf you want to adjust the load balancers attached to your scaling group, you can call the AttachLoadBalancers or DetachLoadBalancers operation.
DBInstanceId
NoteIf you want to adjust the ApsaraDB RDS instances attached to your scaling group, you can call the AttachDBInstances or DetachDBInstances operation.
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
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 Note The value of |
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 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 |
DefaultCooldown | Integer | No | 600 | The cooldown period of the scaling group after a scaling operation is complete. Valid values: 0 to 86400. Unit: seconds. During the cooldown period, Auto Scaling does not execute scaling operations that are triggered by CloudMonitor event-triggered tasks. |
RemovalPolicy.1 | String | No | OldestScalingConfiguration | The first step of the instance removal policy. Valid values:
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:
|
RemovalPolicy.3 | String | No | OldestInstance | The third step of the instance removal policy. Valid values:
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:
Default value: ECS. Note If you want to enable instance health check and load balancer health check at the same time, specify |
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:
|
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 |
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 |
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 a system message which indicates that the preemptible instance will 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
|
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 price across the zones of the scaling group. Valid values: 0 to 10. If you set |
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 specify |
GroupDeletionProtection | Boolean | No | true | Specifies whether to enable the Deletion Protection feature for the scaling group. Valid values:
|
MultiAZPolicy | String | No | PRIORITY | The scaling policy of the multi-zone scaling group of the ECS type. Valid values:
|
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.InstanceType and LaunchTemplateOverride.N.WeightedCapacity. You can specify N 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 instance type N in the scaling group. If you want to scale instances in the scaling group based on the weighted capacity of instances, you must specify this parameter after you specify LaunchTemplateOverride.N.InstanceType. The values of N in the two parameters must be the same. This parameter specifies the weight of instance type N. The weight specifies the capacity of an instance of instance type N in the scaling group. 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. Sample capacity configurations:
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 Note This parameter takes effect only if you specify |
AzBalance | Boolean | No | false | Specifies whether to evenly distribute ECS instances in the scaling group across multiple zones. This parameter takes effect only if you set
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
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
Default value: priority. |
MaxInstanceLifetime | Integer | No | null | The maximum life span of each instance in the scaling group. Unit: seconds. Valid values: 86400 to 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:
|
ScalingPolicy | String | No | recycle | The reclaim mode of the scaling group. Valid values:
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:
Default value: ECS. |
StopInstanceTimeout | Integer | No | 60 | The period of time that is required by each ECS instance to enter the Stopped state during the scale-in process. Unit: seconds. Valid values: 30 to 240. Note
|
CapacityOptions.OnDemandBaseCapacity | Integer | No | 30 | The minimum number of pay-as-you-go instances that must be contained in the scaling group. When the actual number of pay-as-you-go instances in the scaling group drops below the value of this parameter, Auto Scaling preferentially creates pay-as-you-go instances. Valid values: 0 to 1000. If you set |
CapacityOptions.OnDemandPercentageAboveBaseCapacity | Integer | No | 20 | The percentage of pay-as-you-go instances in the excess instances when the minimum number of pay-as-you-go instances is reached. If you set |
CapacityOptions.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
|
CapacityOptions.SpotAutoReplaceOnDemand | Boolean | No | true | Specifies whether to replace pay-as-you-go instances with preemptible instances. If you specify
Default value: false. |
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"]
&StopInstanceTimeout=60
&CapacityOptions={"OnDemandBaseCapacity":30,"OnDemandPercentageAboveBaseCapacity":20,"CompensateWithOnDemand":true,"SpotAutoReplaceOnDemand":true}
&<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 | Description | 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
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
and parameter
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 assigned to ImageId. |
400 | TemplateMissingParameter.InstanceTypes | The input parameter "InstanceTypes" that is mandatory for processing this request is not supplied. | No value is assigned to InstanceTypes. |
400 | TemplateMissingParameter.SecurityGroup | The input parameter "SecurityGroup" that is mandatory for processing this request is not supplied. | No value is assigned to SecurityGroup. |
400 | TemplateVersion.NotNumber | The input parameter "LaunchTemplateVersion" is supposed to be a string representing the version number. | The fixed version number of the launch template contains non-digit characters. |