All Products
Search
Document Center

Auto Scaling:ModifyScalingGroup

Last Updated:Dec 17, 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. 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 or Inactive 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

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

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.
OperationAccess levelResource typeCondition keyAssociated operation
ess:ModifyScalingGroupupdate
*ScalingGroup
acs:ess:{#regionId}:{#accountId}:scalinggroup/{#ScalingGroupId}
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
ScalingGroupIdstringYes

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

asg-bp1ffogfdauy0jw0****
ScalingGroupNamestringNo

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****
MinSizeintegerNo

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
MaxSizeintegerNo

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
DefaultCooldownintegerNo

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
RemovalPoliciesarrayNo

The policy that is used to remove ECS instances from the scaling group. 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.
stringNo

The policy that is used to remove ECS instances from the scaling group. 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.
NewestInstance
ActiveScalingConfigurationIdstringNo

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

asc-bp17pelvl720x5ub****
HealthCheckTypestringNo

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

  • NONE: Auto Scaling does not check the health status of instances.
  • ECS: Auto Scaling checks the health status of instances in the scaling group. If you want to enable instance health check, you can set the value to ECS, regardless of whether the scaling group is of ECS type or Elastic Container Instance type.
  • 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. Default value: ECS.
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
LaunchTemplateIdstringNo

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

lt-m5e3ofjr1zn1aw7****
LaunchTemplateVersionstringNo

The version number of the launch template. Valid values:

  • A fixed template version number.
  • Default: The default template version is always used.
  • Latest: The latest template version is always used.
Default
OnDemandBaseCapacityintegerNo

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 MultiAZPolicy parameter to COMPOSABLE Policy, the default value is 0.

30
OnDemandPercentageAboveBaseCapacityintegerNo

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 MultiAZPolicy parameter to COMPOSABLE Policy, the default value is 100.

20
SpotInstanceRemedybooleanNo

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
CompensateWithOnDemandbooleanNo

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
true
SpotInstancePoolsintegerNo

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 MultiAZPolicy parameter to COMPOSABLE Policy, the default value is 2.

5
DesiredCapacityintegerNo

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
GroupDeletionProtectionbooleanNo

Specifies whether to enable deletion protection for the scaling group. Valid values:

  • true: enables deletion protection for the scaling group. This way, the scaling group cannot be deleted.
  • false: disables deletion protection for the scaling group.
true
MultiAZPolicystringNo

The scaling policy for the multi-zone scaling group that contains ECS instances. Valid values:

  • PRIORITY: ECS instances are scaled based on the vSwitch priority. The first vSwitch specified by using the VSwitchIds parameter 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 scales instances in the zone where the vSwitch that has the next highest priority resides.
  • COST_OPTIMIZED: During a scale-out activity, Auto Scaling preferentially creates ECS instances of the instance type that has the lowest unit price of vCPU. During a scale-in activity, Auto Scaling preferentially removes ECS instances of the instance types that have the highest unit price of vCPU. Auto Scaling preferentially creates preemptible instances when preemptible instance types are specified in the scaling configuration. You can use the CompensateWithOnDemand parameter 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 multiple instance types are specified or at least one instance type is specified for preemptible instances.
  • BALANCE: ECS instances are evenly distributed across zones that are specified in the scaling group. If ECS instances are unevenly distributed among zones due to insufficient resources, you can call the RebalanceInstance operation to evenly distribute the instances among the zones.
  • COMPOSABLE: You can flexibly combine the preceding policies based on your business requirements.
PRIORITY
VSwitchIdsarrayNo

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.

stringNo

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****
LaunchTemplateOverridesarray<object>No

Details of the instance types that are specified in the extended configurations of the launch template.

objectNo

Details of the instance types that are specified in the extended configurations of the launch template.

InstanceTypestringNo

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
WeightedCapacityintegerNo

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:

  • Current capacity: 0
  • Expected capacity: 6
  • Capacity of ecs.c5.xlarge: 4

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
MaxInstanceLifetimeintegerNo

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
AzBalancebooleanNo

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

  • true
  • false

Default value: false.

false
AllocationStrategystringNo

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:

  • priority: Auto Scaling selects instance types based on the 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.

priority
SpotAllocationStrategystringNo

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 MultiAZPolicy parameter to COMPOSABLE. Valid values:

  • priority: Auto Scaling selects instance types based on the 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.

lowestPrice
CustomPolicyARNstringNo

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
ScalingPolicystringNo

The reclaim mode of the scaling group. Valid values:

  • recycle: economical mode

  • release: release mode

  • forcerelease: forced release mode

    **

    Note If you set the value to forcerelease, Auto Scaling forcibly releases instances that are in the Running state during scale-ins. Forced release is equivalent to power outage. If an instance is forcibly released, ephemeral data on the instance will be cleared and cannot be recovered. Exercise caution when you select this option.

  • forcerecycle: forced recycle mode

    **

    Note If you set the value to forcerecycle, Auto Scaling forcibly shuts down instances that are in the Running state during scale-ins. Forced shutdown is equivalent to power outage. If an instance is forcibly shut down, ephemeral data on the instance will be cleared and cannot be recovered. Exercise caution when you select this option.

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
HealthCheckTypesarrayNo

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.
stringNo

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

  • NONE: Auto Scaling does not check the health status of instances.
  • ECS: Auto Scaling checks the health status of instances in the scaling group. If you want to enable instance health check, you can set the value to ECS, regardless of whether the scaling group is of ECS type or Elastic Container Instance type.
  • LOAD_BALANCER: Auto Scaling checks the health status of 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.

ECS
StopInstanceTimeoutintegerNo

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
  • 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 the ECS instance enters the Stopped state or not.
    If you do not specify this parameter, the system proceeds with the scale-in process only after the ECS instance enters the Stopped state. If the ECS instance fails to enter the Stopped state, the scale-in process rolls back, and the scale-in operation is considered as failed.

  • When you call the ModifyScalingGroup operation, you can set the value to 0. In this case, the system ignores this parameter.

60
CapacityOptionsobjectNo

The capacity options.

OnDemandBaseCapacityintegerNo

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 MultiAZPolicy to COMPOSABLE, the default value is 0.

30
OnDemandPercentageAboveBaseCapacityintegerNo

The percentage of pay-as-you-go instances in the excess instances when the minimum number of pay-as-you-go instances is reached. OnDemandBaseCapacity specifies the minimum number of pay-as-you-go instances that must be contained in the scaling group. Valid values: 0 to 100

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

20
CompensateWithOnDemandbooleanNo

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
true
SpotAutoReplaceOnDemandbooleanNo

Specifies whether to replace pay-as-you-go ECS instances with preemptible ECS instances. If you specify CompensateWithOnDemand, it may result in a higher percentage of pay-as-you-go instances compared to the value of OnDemandPercentageAboveBaseCapacity. In this scenario, Auto Scaling will try to deploy preemptible ECS instances to replace the surplus pay-as-you-go ECS instances. When CompensateWithOnDemand is specified, Auto Scaling creates pay-as-you-go ECS instances if there are not enough preemptible instance types. To avoid keeping these pay-as-you-go ECS instances for long periods, Auto Scaling tries to replace them with preemptible instances as soon as enough of preemptible instance types become available. Valid values:

  • true
  • false

Default value: false.

true

Response parameters

ParameterTypeDescriptionExample
object
RequestIdstring

The ID of the request.

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

Examples

Sample success responses

JSONformat

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

Error codes

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
2024-12-03The request parameters of the API has changedView Change Details
2024-10-16The request parameters of the API has changedView Change Details
2024-02-22The request parameters of the API has changedView Change Details
2024-02-01The request parameters of the API has changedView Change Details
2023-10-18The request parameters of the API has changedView Change Details
2022-12-22The internal configuration of the API is changed, but the call is not affectedView Change Details