Modifies a scaling group.

Description

  • The following parameters cannot be modified:
    • RegionId
    • LoadBalancerId
      Note If you want to associate a Server Load Balancer (SLB) instance with a scaling group, call the AttachLoadBalancers operation. If you want to disassociate an SLB instance from a scaling group, call the DetachLoadBalancers operation.
    • DBInstanceId
      Note If you want to associate an ApsaraDB RDS instance with a scaling group, call the AttachDBInstances operation. If you want to disassociate an ApsaraDB RDS instance from a scaling group, call the DetachDBInstances operation.
  • You can call this operation to modify a scaling group only when the scaling group is in the Enabled or Disabled 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 are 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 are within the new range.
  • If the total number of instances in the scaling group does not match the expected number of instances that you specify by changing 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

Parameter Type Required Example Description
Action String Yes ModifyScalingGroup

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

ScalingGroupId String Yes asg-bp1ffogfdauy0jw0****

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

ScalingGroupName String No scalinggroup****

The name of the scaling group. The name of a 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.

MinSize Integer No 1

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 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.
MaxSize Integer No 99

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 valid values of the MaxSize parameter vary based on your usage of Auto Scaling based on your instance quota. You can go to the Quota Center to view the quota of Instances That Can Be Configured for a Scaling Group.

For example, if the quota of Instances That Can Be Configured for a Scaling Group is 2000, the valid values of the MaxSize parameter ranges from 0 to 2000.

DefaultCooldown Integer No 600

The cooldown time after a scaling activity is executed. Valid values: 0 to 86400. Unit: seconds.

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

RemovalPolicy.1 String No OldestScalingConfiguration

The policy that is used to remove ECS instances from the scaling group. Valid values:

  • OldestInstance: removes ECS instances that are added to the scaling group at the earliest point in time.
  • 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.
RemovalPolicy.2 String No NewestInstance

The policy that is used to remove ECS instances from the scaling group. Valid values:

  • OldestInstance: removes ECS instances that are added to the scaling group at the earliest point in time.
  • 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.
ActiveScalingConfigurationId String No asc-bp17pelvl720x5ub****

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

HealthCheckType String No ECS

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.
LaunchTemplateId String No lt-m5e3ofjr1zn1aw7****

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

LaunchTemplateVersion String No Default

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.
OnDemandBaseCapacity Integer No 30

The minimum number of pay-as-you-go instances that are 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.

OnDemandPercentageAboveBaseCapacity Integer No 20

The percentage of pay-as-you-go instances that can be created when instances are added to the scaling group. This parameter takes effect when the number of instances reaches the value of the OnDemandBaseCapacity parameter. Valid values: 0 to 100.

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

SpotInstanceRemedy Boolean No true

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 a system message which indicates that the preemptible instance is to be reclaimed.

CompensateWithOnDemand Boolean No true

Specifies whether to automatically create pay-as-you-go instances to meet the requirement for the number of ECS instances in the scaling group when the number of preemptible instances cannot be reached due to reasons such as costs or insufficient resources. This parameter is valid when the MultiAZPolicy parameter in the CreateScalingGroup operation is set to COST_OPTIMIZED. Valid values:

  • true: Pay-as-you-go instances can be automatically created.
  • false: Pay-as-you-go instances cannot be automatically created.
SpotInstancePools Integer No 5

The number of instance types that are supported. Auto Scaling creates preemptible instances of multiple instance types that are provided at the lowest cost. Valid values: 0 to 10.

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

DesiredCapacity Integer No 5

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

GroupDeletionProtection Boolean No true

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

  • true: Deletion protection is enabled for the scaling group. The scaling group cannot be deleted.
  • false: Deletion protection is disabled for the scaling group.
MultiAZPolicy String No PRIORITY

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

  • PRIORITY: The first vSwitch that is specified by using the VSwitchIds.N 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 attempts to scale instances in the zone where the vSwitch that has the next highest priority resides.
  • COST_OPTIMIZED: During a scale-out activity, Auto Scaling attempts to create ECS instances that have vCPUs provided at the lowest price. During a scale-in activity, Auto Scaling attempts to remove ECS instances that have vCPUs that are provided at the highest price. Preemptible instances are preferentially created when preemptible instance types are specified in the active 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 COST_OPTIMIZED is valid when multiple instance types are specified or at least one preemptible instance type is specified.
  • BALANCE: ECS instances are evenly distributed across multiple zones that are specified in the scaling group. If ECS instances are unevenly distributed across multiple 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.
AzBalance Boolean No false

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

  • true: Instances in the scaling group are evenly distributed across multiple zones.
  • false: Instances in the scaling group are unevenly distributed across multiple zones.

Default value: false.

AllocationStrategy String No priority

The policy that is used to allocate instances. This parameter determines how Auto Scaling selects instance types 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 vCPU to create the required number of instances.

Default value: priority.

SpotAllocationStrategy String No lowestPrice

The policy that is used to allocate 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 vCPU to create the required number of preemptible instances.

Default value: priority.

VSwitchIds.N String No vsw-bp1oo2a7isyrb8igf****

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

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 be 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. As N increases, the priority decreases. When an ECS instance cannot be created in the zone where the vSwitch that has the highest priority resides, Auto Scaling creates the ECS instance in the zone where the vSwitch that has the next highest priority resides.

LaunchTemplateOverride.N.InstanceType String No ecs.c5.xlarge

If you want to scale instances in the scaling group based on the weighted capacity of instance types, you must specify the LaunchTemplateOverride.N.InstanceType and LaunchTemplateOverride.N.WeightedCapacity parameters at the same time.

This parameter specifies instance type N, which overrides the instance type that is specified in the launch template. You can specify N instance types in the extended configurations of the launch template. Valid values of N: 1 to 10

Note This parameter takes effect only when the LaunchTemplateId parameter is specified.

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

LaunchTemplateOverride.N.WeightedCapacity Integer No 4

If you want to scale instances in the scaling group based on the weighted capacity of instance types, you must specify the LaunchTemplateOverride.N.WeightedCapacity parameter after you specify the LaunchTemplateOverride.N.InstanceType parameter. The two parameters have a one-to-one correspondence. The values of N in the two parameters must be the same.

This parameter specifies the weight of the instance type. The weight specifies the capacity of a single instance of the specified instance type in the scaling group.

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.

Examples:

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

To meet the expected capacity, Auto Scaling must create two ecs.c5.xlarge instances.

Note The capacity of the scaling group cannot exceed the sum of the maximum capacity that is specified by the MaxSize parameter and the maximum weight of the instance type.

Valid values of WeightedCapacity in LaunchTemplateOverride.N.WeightedCapacity: 1 to 500.

Response parameters

Parameter Type Example Description
RequestId String 473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E

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
&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}]
&AzBalance=false
&AllocationStrategy=priority
&SpotAllocationStrategy=lowestPrice
&<Common request parameters>

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<ModifyScalingGroupResponse>
    <RequestId>473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E</RequestId>
</ModifyScalingGroupResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

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

Error codes

For a list of error codes, visit the API Error Center.

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 specified scaling group name 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 in the specified scaling configuration is different from that 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 version of the launch template 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 that is specified for the LaunchTemplateVersion parameter of the launch template contains non-digit characters.