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. The computing power refers to the instances that provide the computing capability. When your scaling group cannot meet your business requirements, you can call the ModifyScalingGroup operation to modify 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.
Operation description
-
You cannot modify the following parameters by calling this operation:
- RegionId
- LoadBalancerId
**
Note If you want to modify the load balancer settings of your scaling group, you can call the AttachLoadBalancers operation or the DetachLoadBalancers operation.
- DBInstanceId
**
Note If you want to modify the ApsaraDB RDS instance settings of your scaling group, you can call the AttachDBInstances operation or the DetachDBInstances operation.
-
You can call this operation to modify a scaling group only when the scaling group is in the
Active
orInactive
state. -
Enabling a new scaling configuration in the scaling group will not impact existing Elastic Compute Service (ECS) instances or elastic container instances that were provisioned based on the previous scaling configuration. These instances will continue to run as expected.
-
If the modification of the MaxSize setting leads to the total number of ECS instances or elastic container instances in the scaling group exceeding the new maximum limit, Auto Scaling proactively removes the surplus instances to restore the total number to match the new maximum limit.
-
If the modification of the MinSize setting leads to the total number of ECS instances or elastic container instances in the scaling group exceeding the new minimum threshold, Auto Scaling proactively adds more instances to the scaling group to ensure that the total number aligns with the new minimum threshold.
-
If the modification of the DesiredCapacity setting leads to the total number of ECS instances or elastic container instances in the scaling group not matching the new desired capacity, Auto Scaling proactively adjusts the total number of instances to ensure that the total number aligns with the new desired capacity.
Debugging
Authorization information
The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action
policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:
- Operation: the value that you can use in the Action element to specify the operation on a resource.
- Access level: the access level of each operation. The levels are read, write, and list.
- Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
- The required resource types are displayed in bold characters.
- If the permissions cannot be granted at the resource level,
All Resources
is used in the Resource type column of the operation.
- Condition Key: the condition key that is defined by the cloud service.
- Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
Operation | Access level | Resource type | Condition key | Associated operation |
---|---|---|---|---|
ess:ModifyScalingGroup | update | *ScalingGroup acs:ess:{#regionId}:{#accountId}:scalinggroup/{#ScalingGroupId} |
| none |
Request parameters
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
ScalingGroupId | string | Yes | The ID of the scaling group that you want to modify. | asg-bp1ffogfdauy0jw0**** |
ScalingGroupName | string | No | The name of the scaling group. The name of each 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. | scalinggroup**** |
MinSize | integer | No | The minimum number of ECS instances or elastic container instances that must be contained in the scaling group. If the total number of instances in the scaling group is less than the value of MinSize, Auto Scaling proactively adds instances to the scaling group to ensure that the total number aligns with the minimum threshold. Note
The value of MinSize must be less than or equal to the value of MaxSize.
| 1 |
MaxSize | integer | No | The maximum number of ECS instances or elastic container instances that can be contained in the scaling group. If the total number of instances in the scaling group is greater than the value of MaxSize, Auto Scaling proactively removes the surplus instances from the scaling group to restore the total number to match the maximum limit. The value range of MaxSize is directly correlated with the degree of dependency your business has on Auto Scaling. You can go to Quota Center to check the maximum number of instances that a single scaling group can contain. For example, if a scaling group can contain up to 2,000 instances, the value range of MaxSize is 0 to 2000. | 99 |
DefaultCooldown | integer | No | The cooldown period of the scaling group. This parameter is available only if you set ScalingRuleType to SimpleScalingRule. 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. | 600 |
RemovalPolicies | array | No | The policy that is used to remove ECS instances from the scaling group. Valid values:
| |
string | No | The policy that is used to remove ECS instances from the scaling group. Valid values:
| NewestInstance | |
ActiveScalingConfigurationId | string | No | The ID of the active scaling configuration in the scaling group. | asc-bp17pelvl720x5ub**** |
HealthCheckType | string | No | The health check mode of the scaling group. Valid values:
Note
If you want to enable instance health check and load balancer health check at the same time, we recommend that you specify HealthCheckTypes .
| ECS |
LaunchTemplateId | string | No | The ID of the launch template that is used by Auto Scaling to create instances. | lt-m5e3ofjr1zn1aw7**** |
LaunchTemplateVersion | string | No | The version number of the launch template. Valid values:
| Default |
OnDemandBaseCapacity | integer | No | The minimum number of pay-as-you-go instances that must be included 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 the | 30 |
OnDemandPercentageAboveBaseCapacity | integer | No | The expected percentage of pay-as-you-go instances in the excess instances when the minimum number of pay-as-you-go instances reaches the requirement. Valid values: 0 to 100. If you set the | 20 |
SpotInstanceRemedy | boolean | No | Specifies whether to supplement preemptible instances. If this parameter is set 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. | true |
CompensateWithOnDemand | boolean | No | 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
| true |
SpotInstancePools | integer | No | The number of instance types that you specify. Auto Scaling creates preemptible instances of multiple instance types that are provided at the lowest price. Valid values: 0 to 10. If you set the | 5 |
DesiredCapacity | integer | No | The expected number of ECS instances or elastic container instances in the scaling group. Auto Scaling maintains the expected number of ECS instances or elastic container instances in the scaling group. Make sure that you adhere to the following rule when specifying this parameter: Value of MaxSize ≥ Value of DesiredCapacity ≥ Value of MinSize Note
If you re-enable the Expected Number of Instances feature, you must specify a value for DesiredCapacity again.
| 5 |
GroupDeletionProtection | boolean | No | Specifies whether to enable deletion protection for the scaling group. Valid values:
| true |
MultiAZPolicy | string | No | The scaling policy for the multi-zone scaling group that contains ECS instances. Valid values:
Note
The COST_OPTIMIZED setting takes effect only when multiple instance types are specified or at least one instance type is specified for preemptible instances.
| PRIORITY |
VSwitchIds | array | No | The IDs of vSwitches. This parameter takes effect only when the network type of the scaling group is virtual private cloud (VPC). The specified vSwitches and the scaling group must reside in the same VPC. The vSwitches can reside in different zones. The vSwitches are sorted in ascending order. The first vSwitch specified by using the VSwitchIds parameter has the highest 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. | |
string | No | The IDs of vSwitches. This parameter takes effect only when the network type of the scaling group is VPC. The specified vSwitches and the scaling group must reside in the same VPC. The vSwitches can reside in different zones. The vSwitches are sorted in ascending order. The first vSwitch specified by using the VSwitchIds parameter has the highest 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. | vsw-bp1oo2a7isyrb8igf**** | |
LaunchTemplateOverrides | array<object> | No | Details of the instance types that are specified in the extended configurations of the launch template. | |
object | No | Details of the instance types that are specified in the extended configurations of the launch template. | ||
InstanceType | string | No | The instance type. The instance type that you specify by using the InstanceType parameter overwrites the instance type that is specified in the launch template. If you want Auto Scaling to scale instances in the scaling group based on the instance type weight, you must specify both the InstanceType and WeightedCapacity parameters. Note
This parameter takes effect only after you specify the LaunchTemplateId parameter.
You can use the InstanceType parameter to specify only instance types that are available for purchase. | ecs.c5.xlarge |
WeightedCapacity | integer | No | The weight of the instance type. The weight specifies the capacity of a single instance of the specified instance type in the scaling group. If you want Auto Scaling to scale instances in the scaling group based on the weighted capacity of instances, you must specify the WeightedCapacity parameter after you specify the InstanceType parameter. A higher weight specifies that a smaller number of instances of the specified instance type are required to meet 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:
To meet the expected capacity requirement, Auto Scaling must create and add two ecs.c5.xlarge instances. Note
The capacity of the scaling group cannot exceed the sum of the maximum number of instances that is specified by the MaxSize parameter and the maximum weight of the instance type.
Valid values of the WeightedCapacity parameter: 1 to 500. | 4 |
MaxInstanceLifetime | integer | No | The maximum life span of the 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 indicates that the instance has an unlimited life span in the scaling group. Default value: null. Note
You cannot specify this parameter for scaling groups that manage elastic container instances or scaling groups whose ScalingPolicy is set to recycle.
| null |
AzBalance | boolean | No | Specifies whether to evenly distribute instances in the scaling group across zones. This parameter takes effect only when you set the
Default value: false. | false |
AllocationStrategy | string | No | The allocation policy. Auto Scaling selects instance types based on the allocation policy to create the required number of instances. The policy can be applied to pay-as-you-go instances and preemptible instances at the same time. This parameter takes effect only when you set the MultiAZPolicy parameter to COMPOSABLE. Valid values:
Default value: priority. | priority |
SpotAllocationStrategy | string | No | The allocation policy of preemptible instances. You can use this parameter to individually specify the allocation policy of preemptible instances. This parameter takes effect only when you set the
Default value: priority. | lowestPrice |
CustomPolicyARN | string | No | The ARN of the custom scaling policy (Function). This parameter takes effect only when you specify CustomPolicy as the first step of the instance removal policy. | acs:fc:cn-zhangjiakou:16145688****:services/ess_custom_terminate_policy.LATEST/functions/ess_custom_terminate_policy_name |
ScalingPolicy | string | No | The reclaim mode of the scaling group. Valid values:
ScalingPolicy specifies only the reclaim mode of the scaling group. RemovePolicy of the RemoveInstances operation specifies the manner how instances are removed from the scaling group. For more information, see RemoveInstances . | recycle |
HealthCheckTypes | array | No | The health check mode of the scaling group. Note
You can specify multiple values for this parameter to enable multiple health check options at the same time. If you specify HealthCheckType, this parameter is ignored.
| |
string | No | The health check modes of the scaling group. Valid values:
Default value: ECS. | ECS | |
StopInstanceTimeout | integer | No | The period of time that is required by the Elastic Compute Service (ECS) instance to enter the Stopped state during the scale-in process. Unit: seconds. Valid values: 30 to 240. Note
| 60 |
Response parameters
Examples
Sample success responses
JSON
format
{
"RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3****"
}
Error codes
For a list of error codes, visit the Service error codes.
Change history
Change time | Summary of changes | Operation |
---|---|---|
2024-12-03 | The request parameters of the API has changed | View Change Details |
2024-10-16 | The request parameters of the API has changed | View Change Details |
2024-02-22 | The request parameters of the API has changed | View Change Details |
2024-02-01 | The request parameters of the API has changed | View Change Details |
2023-10-18 | The request parameters of the API has changed | View Change Details |
2022-12-22 | The internal configuration of the API is changed, but the call is not affected | View Change Details |