Call the CreateScalingGroup API to create a scaling group. The group automatically adjusts your computing capacity (the number of instances) by scaling instances of a specified type in or out based on your business requirements and scaling policies.
Operation description
A scaling group is a collection of ECS instances for the same use case.
The number of scaling groups that you can create in a region depends on your Auto Scaling usage. To view your quota for scaling groups, go to Quota Center.
A scaling group is not active immediately after creation. You must call the EnableScalingGroup operation to enable the group before it can trigger scaling activities or execute scaling rules.
The scaling group, as well as its associated Classic Load Balancer (CLB) (formerly SLB) and RDS instances, must be in the same region. For more information, see Regions and availability zones.
If you associate a CLB instance with a scaling group, the scaling group automatically adds new ECS instances to a backend server group of the CLB instance. You can specify which server group to use. The following types of server groups are supported:
-
Default server group: A group of ECS instances that receive requests from the front end. If no vServer group or primary/standby server group is configured for a listener, it forwards requests to the ECS instances in the default server group.
-
vServer group: Use a vServer group if you need to forward different requests to different backend servers, or forward requests based on domain names and URLs.
If you specify both a default server group and one or more vServer groups, the scaling group adds new ECS instances to all specified server groups.
After an instance is added to a backend server group of a CLB instance, its default weight is 50. The CLB instance must meet the following conditions:
-
The CLB instance must be in the active state. You can call the DescribeLoadBalancers operation to check the state of a CLB instance.
-
Health checks must be enabled for all listeners configured on the CLB instance. Otherwise, the scaling group creation fails.
If you associate a scaling group with Application Load Balancer (ALB), Network Load Balancer (NLB), or Gateway Load Balancer (GWLB) server groups, it automatically adds new ECS instances as backend servers to those groups to handle distributed requests. You can specify multiple such server groups, but they must all belong to the same VPC as the scaling group. For more information, see AttachAlbServerGroups or AttachServerGroups.
If you associate an RDS instance with a scaling group, the scaling group automatically adds the internal IP addresses of new ECS instances to the IP address whitelist of the RDS instance. The RDS instance must meet the following conditions:
-
The RDS instance must be in the Running state. You can call the DescribeDBInstances operation to check the state of an RDS instance.
-
The number of IP addresses in the RDS instance's IP address whitelist cannot exceed the limit. For more information, see the Configure an IP address whitelist topic in the RDS documentation.
If the MultiAZPolicy of a scaling group is set to COST_OPTIMIZED:
-
If you specify the
OnDemandBaseCapacity,OnDemandPercentageAboveBaseCapacity, andSpotInstancePoolsparameters, you define the instance allocation strategy for the cost-optimized policy. Auto Scaling prioritizes this strategy during scaling activities. -
If you do not specify the
OnDemandBaseCapacity,OnDemandPercentageAboveBaseCapacity, orSpotInstancePoolsparameters, the cost-optimized policy creates instances by using only the lowest-cost method. In this mode, you cannot create instances by using the Elastic Guarantee service or the Capacity Reservation service.
If you enable tag propagation for a scaling group by setting Tags.Propagate to true:
-
The scaling group propagates its tags only to new instances, not to existing instances.
-
If you specify instance tags in the scaling configuration and also choose to propagate tags from the scaling group, Auto Scaling applies both sets of tags to the new instances.
-
If a tag from the scaling configuration and a propagated tag from the scaling group have the same tag key, the tag value from the scaling configuration takes precedence.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
ess:CreateScalingGroup |
create |
*ScalingGroup
|
None | None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| ScalingGroupName |
string |
No |
The name of the scaling group. The name must be unique within a region. The name must be 2 to 64 characters in length. It must start with a letter, a digit, or a Chinese character and can contain digits, underscores (_), hyphens (-), and periods (.). If you do not specify this parameter, the value of |
scalinggroup**** |
| LaunchTemplateId |
string |
No |
The ID of the launch template that provides the configuration for the scaling group. |
lt-m5e3ofjr1zn1aw7**** |
| LaunchTemplateVersion |
string |
No |
The version of the launch template. Valid values:
|
Default |
| InstanceId |
string |
No |
The ID of an existing instance to use as a template. Auto Scaling uses this instance to create a new scaling configuration for the scaling group. |
i-28wt4**** |
| RegionId |
string |
Yes |
The ID of the region where the scaling group resides. |
cn-qingdao |
| MinSize |
integer |
Yes |
The minimum number of instances in the scaling group. If the total number of instances falls below this value, Auto Scaling adds instances to meet this minimum. Note
The value of |
2 |
| MaxSize |
integer |
Yes |
The maximum number of instances in the scaling group. If the total number of instances exceeds this value, Auto Scaling removes instances to meet this maximum. The value range of If the quota for Maximum number of instances per scaling group is 2,000, the value of |
20 |
| DefaultCooldown |
integer |
No |
The cooldown period, in seconds, after a scaling activity completes. Valid values: 0 to 86400. During the cooldown period, the scaling group does not execute other scaling activities that are triggered by CloudMonitor alarm tasks. Default value: 300. |
300 |
| LoadBalancerIds |
string |
No |
A JSON array of Classic Load Balancer (CLB) instance IDs. The number of CLB instances that you can associate with a single scaling group varies based on your Auto Scaling usage. Go to Quota Center to view the quota for Maximum number of load balancer instances that can be associated with a single scaling group. |
["lb-bp1u7etiogg38yvwz****", "lb-bp168cqrux9ai9l7f****", "lb-bp1jv3m9zvj22ufxp****"] |
| DBInstanceIds |
string |
No |
A JSON array of RDS instance IDs. The number of RDS instances that you can associate with a single scaling group varies based on your Auto Scaling usage. Go to Quota Center to view the quota for Maximum number of RDS instances that can be associated with a single scaling group. |
["rm-bp142f86de0t7****", "rm-bp18l1z42ar4o****", "rm-bp1lqr97h4aqk****"] |
| RemovalPolicies |
array |
No |
The instance removal policies. Valid values:
The term Note
The removal of instances is also affected by the scaling group's multi-AZ policy ( |
|
|
string |
No |
The instance removal policies. Valid values:
The term Note
The removal of instances is also affected by the scaling group's multi-AZ policy ( |
OldestScalingConfiguration |
|
| VSwitchId |
string |
No |
The ID of the vSwitch. If you specify this parameter, the network type of the scaling group is Virtual Private Cloud (VPC). Note
If you do not specify the |
vsw-bp14zolna43z266bq**** |
| MultiAZPolicy |
string |
No |
The scaling policy for ECS instances in a multi-zone scaling group. Valid values:
Default value: |
PRIORITY |
| HealthCheckType |
string |
No |
The health check method for the scaling group. Valid values:
Default value: Note
To enable both instance health checks and load balancer health checks, use the |
ECS |
| ScalingPolicy |
string |
No |
The reclamation mode of the scaling group. Valid values:
|
recycle |
| ClientToken |
string |
No |
A client-generated token to ensure the idempotence of the request. The token must be unique across requests. The token can contain only ASCII characters and cannot exceed 64 characters in length. For more information, see How to ensure idempotence. |
123e4567-e89b-12d3-a456-42665544**** |
| OnDemandBaseCapacity |
integer |
No |
The minimum number of on-demand instances required in the scaling group. Valid values: 0 to 1,000. If the number of on-demand instances is less than this value, Auto Scaling preferentially creates on-demand instances. |
30 |
| OnDemandPercentageAboveBaseCapacity |
integer |
No |
The percentage of on-demand instances among the excess instances after the minimum number of on-demand instances ( |
20 |
| SpotInstanceRemedy |
boolean |
No |
If set to |
true |
| CompensateWithOnDemand |
boolean |
No |
This parameter is effective only when
Default value: |
true |
| SpotInstancePools |
integer |
No |
The number of instance types to use. The scaling group creates spot instances in a balanced manner across the specified number of lowest-cost instance types. Valid values: 1 to 10. |
5 |
| DesiredCapacity |
integer |
No |
The desired number of instances in the scaling group. Auto Scaling automatically maintains this number of instances. The value must be less than or equal to |
5 |
| GroupDeletionProtection |
boolean |
No |
Specifies whether to enable deletion protection for the scaling group. Valid values:
Default value: |
true |
| GroupType |
string |
No |
The type of instances managed by the scaling group. Valid values:
Default value: |
ECS |
| ContainerGroupId |
string |
No |
The ID of the ECI instance, also known as the container group ID. |
eci-uf6fonnghi50u374**** |
| VSwitchIds |
array |
No |
The IDs of one or more vSwitches. If you specify this parameter, the If you specify multiple vSwitches:
Note
If you do not specify the |
|
|
string |
No |
The IDs of one or more vSwitches. If you specify this parameter, the If you specify multiple vSwitches:
Note
If you do not specify the |
vsw-bp14zolna43z266bq**** |
|
| LifecycleHooks |
array<object> |
No |
The list of lifecycle hooks. |
|
|
object |
No |
The list of lifecycle hooks. |
||
| DefaultResult |
string |
No |
The action to take after the wait state ends. Valid values:
If a scale-in (SCALE_IN) activity triggers multiple lifecycle hooks, and the Default value: |
CONTINUE |
| LifecycleHookName |
string |
No |
The name of the lifecycle hook. The name cannot be modified after it is specified. If you do not specify a name, the ID of the lifecycle hook is used. |
lifecyclehook**** |
| LifecycleTransition |
string |
No |
The type of scaling activity to which the lifecycle hook applies. Valid values:
Note
This parameter is required if you specify a lifecycle hook for the scaling group. Other related parameters are optional. |
SCALE_OUT |
| NotificationMetadata |
string |
No |
A fixed string of information for the wait state of a scaling activity. The value cannot exceed 4,096 characters in length. When Auto Scaling sends a message to the specified notification recipient, it includes the value of this parameter. This allows you to manage and categorize notifications. This parameter is valid only when you specify the |
Test |
| NotificationArn |
string |
No |
The Alibaba Cloud Resource Name (ARN) of the notification recipient for the lifecycle hook. Message Service (MNS) queues and topics are supported. The format is
Examples:
|
acs:ess:cn-hangzhou:1111111111:queue/queue2 |
| HeartbeatTimeout |
integer |
No |
The wait time that is defined in the lifecycle hook for a scaling activity. After the wait time expires, the next action is performed. Valid values: 30 to 21600. Unit: seconds. After you create a lifecycle hook, you can call the Default value: 600. |
600 |
| VServerGroups |
array<object> |
No |
The vServer groups to associate with the scaling group. |
|
|
array<object> |
No |
The vServer groups to associate with the scaling group. |
||
| VServerGroupAttributes |
array<object> |
No |
The attributes of the backend server group. |
|
|
object |
No |
The attributes of the backend server group. |
||
| VServerGroupId |
string |
No |
The ID of the vServer group. |
rsp-bp1443g77**** |
| Weight |
integer |
No |
The weight of an instance as a backend server after the instance is added to the vServer group. The higher the weight, the more access requests are distributed to the instance. If the weight is 0, no access requests are distributed to the instance. Valid values: 0 to 100. Default value: 50. |
100 |
| Port |
integer |
No |
The port number used by an instance after it is added to the vServer group. Valid values: 1 to 65535. |
22 |
| LoadBalancerId |
string |
No |
The ID of the Classic Load Balancer (CLB) instance to which the vServer group belongs. |
lb-bp1u7etiogg38yvwz**** |
| Tags |
array<object> |
No |
The tags to apply to the scaling group. |
|
|
object |
No |
The tags to apply to the scaling group. |
||
| Key |
string |
No |
The key of the tag. |
Department |
| Value |
string |
No |
The value of the tag. |
Finance |
| Propagate |
boolean |
No |
Specifies whether the tag can be propagated. Valid values:
Default value: |
false |
| LaunchTemplateOverrides |
array<object> |
No |
The instance type information for extending the launch template. |
|
|
object |
No |
The instance type information for extending the launch template. |
||
| InstanceType |
string |
No |
To enable the scaling group to scale based on instance type capacity, you must specify both this parameter and This parameter specifies the instance type, which overrides the instance type specified in the launch template. Note
This parameter takes effect only when the Must be a valid ECS instance type. |
ecs.c5.xlarge |
| WeightedCapacity |
integer |
No |
To enable the scaling group to scale based on instance type capacity, you must specify this parameter after you specify This parameter specifies the weight of the instance type, which represents the capacity of a single instance of that type in the scaling group. A higher weight means that fewer instances of this type are needed to meet the desired capacity. Because instance types have different performance metrics, such as the number of vCPUs and memory size, you can assign different weights to different instance types based on your requirements. Example:
To meet the desired capacity, the scaling group will create two ecs.c5.xlarge instances. Note
During a scale-out activity, the capacity of the scaling group cannot exceed the sum of the maximum capacity ( Valid values: 1 to 500. |
4 |
| SpotPriceLimit |
number |
No |
The maximum hourly price for the instance type specified in Note
This parameter takes effect only when the |
0.025 |
| AlbServerGroups |
array<object> |
No |
The Application Load Balancer (ALB) server groups to associate with the scaling group. |
|
|
object |
No |
The Application Load Balancer (ALB) server groups to associate with the scaling group. |
||
| AlbServerGroupId |
string |
No |
The ID of the ALB server group. A scaling group can be associated with a limited number of ALB server groups. To view or request a quota increase, go to Quota Center. |
sgp-ddwb0y0g6y9bjm**** |
| Weight |
integer |
No |
The weight of an instance as a backend server after the instance is added to the ALB server group. The higher the weight, the more access requests are distributed to the instance. If the weight is 0, no access requests are distributed to the instance. Valid values: 0 to 100. |
100 |
| Port |
integer |
No |
The port number used by an instance after it is added to the ALB server group. Valid values: 1 to 65535. |
22 |
| ServerGroups |
array<object> |
No |
The load balancer server groups. Note
You cannot specify the same server group in both |
|
|
object |
No |
The load balancer server groups. |
||
| ServerGroupId |
string |
No |
The ID of the server group. |
sgp-5yc3bd9lfyh***** |
| Type |
string |
No |
The type of the server group. Valid values:
|
ALB |
| Weight |
integer |
No |
The weight of an instance as a backend server after the instance is added to the server group. Valid values: 0 to 100. A higher weight indicates that more access requests are distributed to the instance. If the weight is 0, no access requests are distributed to the instance. Note
This parameter is required for ALB and NLB server groups. You cannot set this parameter for GWLB server groups. |
100 |
| Port |
integer |
No |
The port number used by an instance after it is added to the server group. Valid values: 1 to 65535. |
22 |
| AzBalance |
boolean |
No |
Specifies whether to evenly distribute the capacity of the scaling group across multiple availability zones. This parameter is valid only when
Note
If Default value: |
false |
| AllocationStrategy |
string |
No |
The capacity allocation policy determines how the scaling group selects available instance types to meet capacity requirements. The policy applies to both on-demand and preemptible capacity (effective only when the
Default value: priority. |
priority |
| SpotAllocationStrategy |
string |
No |
The distribution strategy for spot capacity. You can use this parameter to specify a separate strategy for spot capacity (effective only when the
Default value: priority. |
lowestPrice |
| SyncAlarmRuleToCms |
boolean |
No |
Note
This parameter is not yet available. |
false |
| MaxInstanceLifetime |
integer |
No |
The maximum lifetime of an instance in the scaling group. Unit: seconds. Value range: [86400, Integer.maxValue]. Default value: null. |
null |
| CustomPolicyARN |
string |
No |
The ARN of the custom scale-in policy function. This parameter is valid only when the first removal policy in |
acs:fc:cn-zhangjiakou:16145688****:services/ess_custom_terminate_policy.LATEST/functions/ess_custom_terminate_policy_name |
| ResourceGroupId |
string |
No |
The ID of the resource group to which the new scaling group belongs. Note
If you do not specify this parameter, the new scaling group is added to the default resource group. |
rg-123****** |
| LoadBalancerConfigs |
array<object> |
No |
The load balancer configurations. |
|
|
object |
No |
The load balancer configurations. |
||
| LoadBalancerId |
string |
No |
The ID of the CLB instance. |
lb-2zen1olhfg9yw3f4q**** |
| Weight |
integer |
No |
The weight of an instance as a backend server after the instance is added to the SLB server group. The higher the weight, the more access requests are distributed to the instance. If the weight is 0, no access requests are distributed to the instance. Valid values: 0 to 100. |
10 |
| HealthCheckTypes |
array |
No |
The health check methods for the scaling group. Note
You can use this parameter to set multiple values and enable multiple health check options. If you set the |
|
|
string |
No |
The health check methods for the scaling group. Valid values:
Default value: |
ECS |
|
| DBInstances |
array<object> |
No |
The databases that are associated with the scaling group. |
|
|
object |
No |
The database configurations that are associated with the scaling group. |
||
| DBInstanceId |
string |
No |
The ID of the database instance. |
rm-m5eqju85s45mu0*** |
| Type |
string |
No |
The type of the database. Valid values:
Default value: RDS. |
RDS |
| AttachMode |
string |
No |
The method that is used to associate the scaling group with the database. Valid values:
|
SecurityIp |
| StopInstanceTimeout |
integer |
No |
The timeout period for the system to wait for an ECS instance to be stopped during a scale-in event. Unit: seconds. Valid values: 30 to 240. Note
|
60 |
| CapacityOptions |
object |
No |
The capacity options. |
|
| OnDemandBaseCapacity |
integer |
No |
The minimum number of on-demand instances required in the scaling group. When the number of on-demand instances in the scaling group is less than this value, the system preferentially creates on-demand instances. Valid values: 0 to 1,000. When |
30 |
| OnDemandPercentageAboveBaseCapacity |
integer |
No |
The percentage of on-demand instances among the excess instances after the When |
20 |
| CompensateWithOnDemand |
boolean |
No |
When
Default value: |
true |
| SpotAutoReplaceOnDemand |
boolean |
No |
After you enable
Default value: |
false |
| PriceComparisonMode |
string |
No |
The price comparison mode for the cost optimization strategy of the scaling group. Valid values:
Default value: |
PricePerUnit |
| BalanceMode |
string |
No |
The zone balancing mode is effective only when enabled. Valid values:
Default value: BalancedBestEffort. |
BalancedBestEffort |
| AutoRebalance |
boolean |
No |
Specifies whether to enable automatic balancing for the scaling group. This setting takes effect only when BalancedOnly is enabled for a scaling group that is balanced across availability zones. Value range:
Default value: false. |
false |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
|||
| RequestId |
string |
The ID of the request. |
473469C7-AA6F-4DC5-B3DB-A3DC0DE3**** |
| ScalingGroupId |
string |
The ID of the scaling group. |
asg-bp14wlu85wrpchm0**** |
Examples
Success response
JSON format
{
"RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3****",
"ScalingGroupId": "asg-bp14wlu85wrpchm0****"
}
Error codes
|
HTTP status code |
Error code |
Error message |
Description |
|---|---|---|---|
| 404 | ResourceNotAvailable.VPCNetwork | The specified zone does not support vpc network or sold out. |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.