All Products
Search
Document Center

Auto Scaling:ModifyScalingGroup

Last Updated:Mar 26, 2024

Modifies a scaling group.

Operation description

  • You cannot call this operation to modify the settings of the following parameters:

    • RegionId

    • LoadBalancerId

    Note If you want to change the CLB instances that are associated with your scaling group, call the AttachLoadBalancers and DetachLoadBalancers operations.
    • DBInstanceId

    Note If you want to change the ApsaraDB RDS instances that are associated with your scaling group, call the AttachDBInstances and DetachDBInstances operations.
  • You can modify only scaling groups that are in the Active or Inactive state.

  • If you enable a new scaling configuration, Elastic Compute Service (ECS) instances that are created based on the previous scaling configuration still run as expected in the scaling group.

  • If the total number of instances in the scaling group is greater than the allowed maximum number after you change the value of the MaxSize parameter, Auto Scaling automatically removes instances from the scaling group to ensure that the number of instances is within the new range.

  • If the total number of instances in the scaling group is less than the allowed minimum number after you change the value of the MinSize parameter, Auto Scaling automatically adds instances to the scaling group to ensure that the number of instances is within the new range.

  • If the total number of instances in the scaling group does not match the expected number of instances after you change the value of the DesiredCapacity parameter, Auto Scaling automatically adds instances to or removes instances from the scaling group to ensure that the number of instances matches the value of the DesiredCapacity parameter.

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 in the scaling group. When the number of ECS instances in the scaling group is less than the value of the MinSize parameter, Auto Scaling automatically creates ECS instances and adds the instances to the scaling group until the number of instances is equal to the value of the MinSize parameter.

Note The value of the MinSize parameter must be less than or equal to the value of the MaxSize parameter.
1
MaxSizeintegerNo

The maximum number of ECS instances in the scaling group. When the number of ECS instances in the scaling group is greater than the value of the MaxSize parameter, Auto Scaling automatically removes ECS instances from the scaling group until the number of instances is equal to the value of the MaxSize parameter.

The value range of the MaxSize parameter varies based on the instance quota. You can go to Quota Center to check the quota of instances that can be included in a scaling group.

For example, if the quota of instances that can be included in a scaling group is 2000, the valid values of the MaxSize parameter range from 0 to 2000.

99
DefaultCooldownintegerNo

The default cooldown time of the scaling group. This parameter takes effect only for scaling groups that have simple scaling rules. Valid values: 0 to 86400. Unit: seconds. During the cooldown time, Auto Scaling executes only scaling activities that are triggered by event-triggered tasks associated with CloudMonitor.

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 in the scaling group.
  • ECS: Auto Scaling checks the health status of Elastic Compute Service (ECS) 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 of instances in the scaling group.
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 costs and insufficient resources. This parameter takes effect only if you set the MultiAZPolicy parameter 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 in the scaling group. Auto Scaling automatically maintains the specified expected number of ECS instances. The expected number cannot be greater than the value of the MaxSize parameter and cannot be less than the value of the MinSize parameter.

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 check the health status of instances in the scaling group.
  • ECS: Auto Scaling checks the health status of ECS 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 of instances in the scaling group.
stringNo

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

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