All Products
Search
Document Center

Auto Scaling:ModifyScalingGroup

Last Updated:Jun 24, 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

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer.

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:ModifyScalingGroupWrite
  • 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 perform health checks.
  • ECS: Auto Scaling checks the health status of ECS instances in the scaling group.
  • ECI: Auto Scaling checks the health status of elastic container 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.
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****
LaunchTemplateOverridesobject []No

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

  • NONE: Auto Scaling does not perform health checks.
  • ECS: Auto Scaling checks the health status of ECS instances in the scaling group.
  • ECI: Auto Scaling checks the health status of elastic container 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 CLB instances are not supported as the health check basis for instances in the scaling group.
stringNo

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

  • NONE: Auto Scaling does not perform health checks.
  • ECS: Auto Scaling checks the health status of ECS instances in the scaling group.
  • ECI: Auto Scaling checks the health status of elastic container 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 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.
ECS

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-02-22The request parameters of the API has changedsee changesets
Change itemChange content
Input ParametersThe request parameters of the API has changed.
    Added Input Parameters: ScalingPolicy
2024-02-01The request parameters of the API has changedsee changesets
Change itemChange content
Input ParametersThe request parameters of the API has changed.
    Added Input Parameters: HealthCheckTypes
2023-10-18The request parameters of the API has changedsee changesets
Change itemChange content
Input ParametersThe request parameters of the API has changed.
    Added Input Parameters: DisableDesiredCapacity
2022-12-22The internal configuration of the API is changed, but the call is not affectedsee changesets
Change itemChange content
The internal configuration of the API is changed, but the call is not affected.