Modifies a scaling group.

Description

  • You cannot modify the settings of the following parameters:
    • RegionId
    • LoadBalancerId
      Note If you want to disassociate your scaling group from a Classic Load Balancer (CLB) instance, you can call the DetachLoadBalancers operation. If you want to associate your scaling group with another CLB instance, you can call the AttachLoadBalancers operation.
    • DBInstanceId
      Note If you want to disassociate your scaling group from an ApsaraDB RDS instance, you can call the DetachDBInstances operation. If you want to associate your scaling group with another ApsaraDB RDS instance, you can call the AttachDBInstances operation.
  • You can modify a scaling group only when the scaling group is 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 excess 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. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

ParameterTypeRequiredExampleDescription
ActionStringYesModifyScalingGroup

The operation that you want to perform. Set the value to ModifyScalingGroup.

ScalingGroupIdStringYesasg-bp1ffogfdauy0jw0****

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

ScalingGroupNameStringNoscalinggroup****

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.

MinSizeIntegerNo1

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 adds ECS instances 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.
MaxSizeIntegerNo99

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 added to a scaling group.

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

DefaultCooldownIntegerNo600

The cooldown time of the scaling group after a scaling activity is triggered. Valid values: 0 to 86400. Unit: seconds.

During the cooldown time, Auto Scaling executes only scaling activities that are triggered by event-triggered tasks monitored by CloudMonitor.

RemovalPolicy.1StringNoOldestScalingConfiguration

The first step 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.
  • CustomPolicy: removes ECS instances based on the custom scale-in policy (Function).
Note The scaling configuration source specified by OldestScalingConfiguration can be a scaling configuration or a launch template. The CustomPolicy setting is available only for the RemovalPolicy.1 parameter. If you set the RemovalPolicy.1 parameter to CustomPolicy, you must also specify the CustomPolicyARN parameter.
RemovalPolicy.2StringNoNewestInstance

The second step 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.
    Note The scaling configuration source specified by OldestScalingConfiguration can be a scaling configuration or a launch template.
RemovalPolicy.3StringNoOldestInstance

The third step 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.
Note The scaling configuration source specified by OldestScalingConfiguration can be a scaling configuration or a launch template.
ActiveScalingConfigurationIdStringNoasc-bp17pelvl720x5ub****

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

HealthCheckTypeStringNoECS

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

  • NONE: Auto Scaling does not perform health checks on instances in the scaling group.
  • ECS: Auto Scaling performs health checks on ECS instances in the scaling group.
LaunchTemplateIdStringNolt-m5e3ofjr1zn1aw7****

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

LaunchTemplateVersionStringNoDefault

The version number of the launch template. Valid values:

  • A fixed template version number.
  • Default: the default template version.
  • Latest: the latest template version.
OnDemandBaseCapacityIntegerNo30

The minimum number of pay-as-you-go instances required 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 the MultiAZPolicy parameter is set to COMPOSABLE Policy, the default value is 0.

OnDemandPercentageAboveBaseCapacityIntegerNo20

The percentage of pay-as-you-go instances among the excess instances when the requirement on the minimum number of pay-as-you-go instances is met. Valid values: 0 to 100.

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

SpotInstanceRemedyBooleanNotrue

Specifies whether to supplement preemptible instances. If you set this parameter to true, Auto Scaling creates an instance to replace a preemptible instance when Auto Scaling receives a system message that indicates the preemptible instance is to be reclaimed.

CompensateWithOnDemandBooleanNotrue

Specifies whether to automatically create pay-as-you-go instances to meet the requirement 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
SpotInstancePoolsIntegerNo5

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

DesiredCapacityIntegerNo5

The expected number of ECS instances in the scaling group. Auto Scaling automatically maintains the expected number of ECS instances that you specify. The expected number cannot be greater than the value of the MaxSize parameter and cannot be less than the value of the MinSize parameter.

GroupDeletionProtectionBooleanNotrue

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

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

  • PRIORITY: The first vSwitch specified by using the VSwitchIds.N parameter has the highest priority. Auto Scaling 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: Auto Scaling creates ECS instances whose vCPUs are provided at the lowest price during scale-out activities and removes ECS instances whose vCPUs are provided at the highest price during scale-in activities. If preemptible instance types are specified in the active scaling configuration, Auto Scaling preferentially creates preemptible instances. 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 you specify multiple instance types or when you specify at least one preemptible instance type.
  • BALANCE: Auto Scaling evenly distributes ECS instances across zones that are specified for the scaling group. If ECS instances are unevenly distributed across zones due to insufficient resources, you can call the RebalanceInstance operation to evenly distribute the instances across the zones.
  • COMPOSABLE: You can flexibly combine the preceding policies based on your business requirements.
VSwitchIds.NStringNovsw-bp1oo2a7isyrb8igf****

The ID of vSwitch N. Valid values of N: 1 to 5.

This parameter is available only if 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 based on the value of N. 1 specifies the highest priority. A greater value of N specifies a lower 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.

LaunchTemplateOverride.N.InstanceTypeStringNoecs.c5.xlarge

Instance type N. The instance type that is specified by using this parameter overrides the instance type that is specified in the launch template. If you want to scale instances in the scaling group based on the weighted capacity of instances, you must specify the LaunchTemplateOverride.N.InstanceType and LaunchTemplateOverride.N.WeightedCapacity parameters at the same time.

You can specify N instance types by using the Extended Configurations feature of the launch template. Valid values of N: 1 to 10.

Note This parameter is available only if you specify the LaunchTemplateId parameter.

For information about the valid values of InstanceType in InstanceTypeOverride.N.InstanceType, see Overview of instance families.

LaunchTemplateOverride.N.WeightedCapacityIntegerNo4

The weight of instance type N. The weight of an instance type specifies the capacity of a single instance of the instance type in the scaling group. If you want to scale instances in the scaling group based on the weighted capacity of instances, you must specify the LaunchTemplateOverride.N.WeightedCapacity parameter after you specify the LaunchTemplateOverride.N.InstanceType parameter. The values of N in the two parameters must be the same.

A higher weight specifies that a smaller number of instances of the specified instance type are required to meet the expected capacity requirement.

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 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 WeightedCapacity in the InstanceTypeOverride.N.WeightedCapacity parameter: 1 to 500.

LaunchTemplateOverride.N.SpotPriceLimitFloatNo0.025

The maximum bid price of instance type N that is specified by the LaunchTemplateOverride.N.InstanceType parameter. You can specify N instance types by using the Extended Configurations feature of the launch template. Valid values of N: 1 to 10.

Note This parameter is available only if you specify the LaunchTemplateId parameter.
AzBalanceBooleanNofalse

Specifies whether to evenly distribute instances in the scaling group across multiple zones. This parameter is available only if you set the MultiAZPolicy parameter to COMPOSABLE. Valid values:

  • true
  • false

Default value: false.

AllocationStrategyStringNopriority

The allocation policy of instances. Auto Scaling selects instance types based on the allocation policy to create instances. The policy can be applied to pay-as-you-go instances and preemptible instances. This parameter is available only if you set the MultiAZPolicy parameter to COMPOSABLE. Valid values:

  • priority: Auto Scaling selects instance types based on the specified orders of the instance types to create instances.
  • lowestPrice: Auto Scaling selects instance types that have the lowest unit price of vCPU to create instances.

Default value: priority.

SpotAllocationStrategyStringNolowestPrice

The allocation policy of preemptible instances. You can use this parameter to individually specify the allocation policy of preemptible instances. This parameter is available only if you set the MultiAZPolicy parameter to COMPOSABLE. Valid values:

  • priority: Auto Scaling selects instance types based on the specified orders of the instance types to create preemptible instances.
  • lowestPrice: Auto Scaling selects instance types that have the lowest unit price of vCPU to create preemptible instances.

Default value: priority.

MaxInstanceLifetimeIntegerNonull

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. If you set this parameter to 0, the instance has an unlimited life span.

Default value: null.

Note You cannot specify this parameter for scaling groups that contain elastic container instances or scaling groups whose ScalingPolicy is set to recycle.
CustomPolicyARNStringNoacs:fc:cn-zhangjiakou:16145688****:services/ess_custom_terminate_policy.LATEST/functions/ess_custom_terminate_policy_name

The Alibaba Cloud Resource Name (ARN) of the custom scale-in policy (Function). This parameter is available only if you specify CustomPolicy as the first step of the instance removal policy.

Response parameters

ParameterTypeExampleDescription
RequestIdString473469C7-AA6F-4DC5-B3DB-A3DC0DE3****

The ID of the request.

Examples

Sample requests

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
&<Common request parameters>

Sample 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 a list of error codes, see Service error codes.

HTTP status code

Error code

Error message

Description

404

InvalidScalingGroupId.NotFound

The specified scaling group does not exist.

The error message returned because the specified scaling group does not exist within the Alibaba Cloud account.

400

InvalidScalingGroupName.Duplicate

The specified value of parameter &lt;parameter name&gt; is duplicated.

The error message returned because the name that you specified for the scaling group already exists.

404

InvalidScalingConfigurationId.NotFound

The specified scaling configuration does not exist.

The error message returned because 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 error message returned because the instance type of the specified scaling configuration is different from the instance type of the active scaling configuration.

400

InvalidParameter.Conflict

The value of parameter

parameter name

and parameter

parameter name

are confilict.

The error message returned because the value of the MinSize parameter is greater than the value of the MaxSize parameter.

400

LaunchTemplateVersionSet.NotFound

The specific version of launch template is not exist.

The error message returned because the specified launch template version does not exist.

400

LaunchTemplateSet.NotFound

The specified launch template set is not found.

The error message returned because 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 error message returned because the ImageId parameter that is required for the specified launch template is not specified.

400

TemplateMissingParameter.InstanceTypes

The input parameter "InstanceTypes" that is mandatory for processing this request is not supplied.

The error message returned because the InstanceTypes parameter that is required for the specified launch template is not specified.

400

TemplateMissingParameter.SecurityGroup

The input parameter "SecurityGroup" that is mandatory for processing this request is not supplied.

The error message returned because the SecurityGroup parameter that is required for the specified launch template is not specified.

400

TemplateVersion.NotNumber

The input parameter "LaunchTemplateVersion" is supposed to be a string representing the version number.

The error message returned because the fixed version number specified for the LaunchTemplateVersion parameter of the launch template contains non-digit characters.