A scaling group automatically adjusts your computing capacity by adding or removing instances based on your business needs and policies. If the properties of a scaling group no longer meet your business requirements, you can call the ModifyScalingGroup operation to modify properties such as the maximum, minimum, or expected number of instances. This saves time and resources because you do not need to create and reconfigure a new scaling group.
Usage notes
You cannot modify the following parameters:
RegionId
LoadBalancerId
NoteTo modify the Server Load Balancer instances, call the AttachLoadBalancers and DetachLoadBalancers operations.
DBInstanceId
NoteTo modify the RDS instances, call the AttachDBInstances and DetachDBInstances operations.
You can call this operation only when the scaling group is in the Active or Inactive state.
Enabling a new scaling configuration does not affect running Elastic Compute Service (ECS) or Elastic Container Instance (ECI) instances that were created based on a previous scaling configuration.
If you modify MaxSize, and the number of ECS or ECI instances in the scaling group exceeds the new MaxSize, Auto Scaling automatically removes instances until the number of instances is equal to MaxSize.
If you modify MinSize, and the number of ECS or ECI instances in the scaling group is less than the new MinSize, Auto Scaling automatically adds instances until the number of instances is equal to MinSize.
If you modify DesiredCapacity, and the number of ECS or ECI instances in the scaling group does not match the new DesiredCapacity, Auto Scaling automatically adds or removes instances until the number of instances is equal to DesiredCapacity.
Try it now
Request parameters
Parameter | Type | Required | Example | Description |
Action | String | Yes | ModifyScalingGroup | A required parameter. Set the value to ModifyScalingGroup. |
ScalingGroupId | String | Yes | asg-bp1ffogfdauy0jw0**** | The ID of the scaling group to modify. |
ScalingGroupName | String | No | scalinggroup**** | The name of the scaling group. The name must be unique within a region. The name must be 2 to 64 characters in length. It must start with a digit, an uppercase or lowercase letter, or a Chinese character. It can contain digits, underscores (_), hyphens (-), and periods (.). |
MinSize | Integer | No | 1 | The minimum number of ECS or ECI instances in the scaling group. If the number of instances in the scaling group is less than the value of Note
|
MaxSize | Integer | No | 99 | The maximum number of ECS or ECI instances in the scaling group. If the number of instances in the scaling group is greater than the value of The value range of MaxSize depends on your Auto Scaling usage. Go to Quota Center to view the quota for the Maximum number of instances in a scaling group. For example, if the quota for the Maximum number of instances in a scaling group is 2000, the value range of |
DefaultCooldown | Integer | No | 600 | The cooldown period after a scaling activity that adds or removes ECS or ECI instances is complete. Valid values: 0 to 86400. Unit: seconds. During the cooldown period, the scaling group does not execute other scaling activities. This applies only to scaling activities triggered by event-triggered tasks from CloudMonitor. |
RemovalPolicy.1 | String | No | OldestScalingConfiguration | The first removal policy for ECS instances. Valid values:
Note The instance configuration source mentioned in OldestScalingConfiguration refers to either a scaling configuration or a launch template. CustomPolicy can only be set as the first removal policy. If you set this policy, you must also specify the CustomPolicyARN parameter. |
RemovalPolicy.2 | String | No | NewestInstance | The second removal policy for ECS instances. Valid values:
|
RemovalPolicy.3 | String | No | OldestInstance | The third removal policy for ECS instances. Valid values:
Note The instance configuration source mentioned in OldestScalingConfiguration refers to either 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 To enable both instance health checks and load balancer health checks, use the |
LaunchTemplateId | String | No | lt-m5e3ofjr1zn1aw7**** | The ID of the launch template. The scaling group uses the launch template to obtain configuration information for creating instances. |
LaunchTemplateVersion | String | No | Default | The version of the launch template. Valid values:
|
OnDemandBaseCapacity | Integer | No | 30 | The minimum number of on-demand instances required in the scaling group. Valid values: 0 to 1000. When the number of on-demand instances is less than this value, on-demand instances are created first. When the |
OnDemandPercentageAboveBaseCapacity | Integer | No | 20 | The percentage of on-demand instances among the instances that exceed the OnDemandBaseCapacity. This applies after the minimum number of on-demand instances is met. Valid values: 0 to 100. When the |
SpotInstanceRemedy | Boolean | No | true | Specifies whether to supplement spot instances. If enabled, when the system receives a message that a spot instance is about to be reclaimed, the scaling group attempts to create a new instance to replace it. |
CompensateWithOnDemand | Boolean | No | true | When the
|
SpotInstancePools | Integer | No | 5 | The number of available instance types. The scaling group creates spot instances of multiple types that have the lowest cost in a balanced manner. Valid values: 0 to 10. When the |
DesiredCapacity | Integer | No | 5 | The expected number of ECS or ECI instances in the scaling group. Setting this parameter enables the expected number of instances feature. The scaling group automatically maintains the number of instances at this value. The value must be between MaxSize and MinSize, inclusive. Note If you disable and then re-enable the expected number of instances feature, you must set the |
GroupDeletionProtection | Boolean | No | true | Specifies whether to enable deletion protection for the scaling group. Valid values:
|
MultiAZPolicy | String | No | PRIORITY | The scaling policy for a multi-zone scaling group of ECS instances. Valid values:
|
VSwitchIds.N | String | No | vsw-bp1oo2a7isyrb8igf**** | The ID of one or more vSwitches. Valid values of N: 1 to 5. This parameter is effective only when the network type of the scaling group is VPC. The specified vSwitches must belong to the same VPC as the scaling group. The vSwitches can be in different zones. The priority of the vSwitches is sorted in ascending order. A value of 1 indicates the highest priority. If an ECS instance cannot be created in the zone of a higher-priority vSwitch, the system automatically tries to create the instance in the zone of the next-highest priority vSwitch. |
LaunchTemplateOverride.N.InstanceType | String | No | ecs.c5.xlarge | To scale a scaling group based on instance type capacity, specify both this parameter and LaunchTemplateOverride.N.WeightedCapacity. This parameter specifies an instance type that overwrites the instance type in the launch template. You can specify N parameters to extend the launch template to support N instance types. Valid values of N: 1 to 20. Note This parameter is effective only when the LaunchTemplateId parameter specifies a launch template. For a list of available ECS instance types, see Instance families. |
LaunchTemplateOverride.N.WeightedCapacity | Integer | No | 4 | After you specify LaunchTemplateOverride.N.InstanceType, specify this parameter to scale the group based on instance type capacity. The value of N must be the same for both parameters. This parameter specifies the weight of the instance type. The weight represents the capacity of a single instance of this type in the scaling group. A higher weight means that fewer instances of this type are needed to meet the expected capacity. Performance metrics, such as the number of vCPUs and memory size, can vary between instance types. You can set different weights for different instance types based on your needs. For example:
To meet the expected capacity, the scaling group will scale out two ecs.c5.xlarge instances. Note During a scale-out, the capacity of the scaling group cannot exceed the sum of the maximum capacity (MaxSize) and the highest weight of an instance type. Valid values for WeightedCapacity: 1 to 500. |
LaunchTemplateOverride.N.SpotPriceLimit | Float | No | 0.025 | The maximum bid price for the instance type specified by Note This parameter is effective only when the |
AzBalance | Boolean | No | false | Specifies whether to evenly distribute the capacity of the scaling group across multiple zones. This parameter is effective only when MultiAZPolicy is set to COMPOSABLE. Valid values:
Default value: false. |
AllocationStrategy | String | No | priority | The capacity allocation policy. It determines how the scaling group selects available instance types to meet the capacity requirements. This policy applies to both on-demand and spot capacity. This parameter is effective only when MultiAZPolicy is set to COMPOSABLE. Valid values:
Default value: priority. |
SpotAllocationStrategy | String | No | lowestPrice | The distribution policy for spot capacity. You can use this parameter to separately specify the distribution policy for spot capacity. This parameter is effective only when MultiAZPolicy is set to COMPOSABLE. Valid values:
Default value: priority. |
MaxInstanceLifetime | Integer | No | null | The maximum lifetime of an instance in the scaling group. Unit: seconds. Valid values: 0 or a value in the range of [ Default value: null. Note This parameter is not supported for scaling groups of the ECI type or for scaling groups with Economical Mode enabled. |
CustomPolicyARN | String | No | acs:fc:cn-zhangjiakou:16145688****:services/ess_custom_terminate_policy.LATEST/functions/ess_custom_terminate_policy_name | The ARN of the custom scale-in policy function. This is effective only when the first removal policy in RemovalPolicies is set to CustomPolicy. |
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 reclamation mode of the scaling group. Valid values:
ScalingPolicy specifies the reclamation mode of the scaling group. The specific action taken when an instance is removed from the scaling group is determined by the RemovePolicy parameter of the RemoveInstances API. For more information, see RemoveInstances. |
HealthCheckTypes.N | String | No | ECS | A list of health check modes for the scaling group. Valid values:
Default value: ECS. |
StopInstanceTimeout | Integer | No | 60 | The timeout period for an ECS instance to be successfully stopped during a scale-in process. Unit: seconds. Valid values: 30 to 240. Note
|
CapacityOptions.OnDemandBaseCapacity | Integer | No | 30 | The minimum number of on-demand instances required in an existing scaling group. When the number of on-demand instances in the scaling group is less than this value, the system creates on-demand instances first. Valid values: 0 to 1000. When the |
CapacityOptions.OnDemandPercentageAboveBaseCapacity | Integer | No | 20 | The percentage of on-demand instances among the instances that exceed the When the |
CapacityOptions.CompensateWithOnDemand | Boolean | No | true | When the
|
CapacityOptions.SpotAutoReplaceOnDemand | Boolean | No | true | After
Default value: false. |
CapacityOptions.PriceComparisonMode | String | No | PricePerUnit | The price comparison mode for the scaling group's cost optimization policy. Valid values:
Default value: PricePerUnit. |
BalanceMode | String | No | BalancedBestEffort | The zone balancing mode. This is effective only when zone balancing is enabled. Valid values:
Default value: BalancedBestEffort. |
AutoRebalance | Boolean | No | false | Specifies whether to enable automatic rebalancing for the scaling group. This is effective only when BalancedOnly is enabled for a zone-balanced scaling group. Valid values:
Default value: false. |
Response parameters
Parameter | Type | Example | Description |
RequestId | String | 473469C7-AA6F-4DC5-B3DB-A3DC0DE3**** | The request ID. |
Examples
Sample request
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 parametersSample 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 more information about error codes, see the Error Center.
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 in your account. |
400 | InvalidScalingGroupName.Duplicate | The specified value of parameter
is duplicated. | The scaling group name already exists. |
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 of the specified scaling configuration does not match the instance type of the active scaling configuration. |
400 | InvalidParameter.Conflict | The value of parameter
and parameter
are in conflict. | The specified MinSize is greater than MaxSize. |
400 | LaunchTemplateVersionSet.NotFound | The specific version of launch template is not exist. | The specified version of the launch template does not exist. |
400 | LaunchTemplateSet.NotFound | The specified launch template set is not found. | The specified launch template does not exist. |
400 | TemplateMissingParameter.ImageId | The input parameter "ImageId" that is mandatory for processing this request is not supplied. | The specified version of the launch template is missing image information. |
400 | TemplateMissingParameter.InstanceTypes | The input parameter "InstanceTypes" that is mandatory for processing this request is not supplied. | The specified version of the launch template is missing instance type information. |
400 | TemplateMissingParameter.SecurityGroup | The input parameter "SecurityGroup" that is mandatory for processing this request is not supplied. | The specified version of the launch template is missing security group information. |
400 | TemplateVersion.NotNumber | The input parameter "LaunchTemplateVersion" is supposed to be a string representing the version number. | The specified fixed version number of the launch template must be a number. |