Creates a scaling group.
Description
A scaling group is a group of Elastic Compute Service (ECS) instances that can be used in similar business scenarios.
The number of scaling groups that can be created in a region depends on your usage of Auto Scaling. You can go to the Quota Center to check the quota of the Total Scaling Groups.
A scaling group does not immediately take effect after it is created. You must call the EnableScalingGroup operation to enable the scaling group. After the scaling group is enabled, Auto Scaling can execute scaling rules to trigger scaling activities in the scaling group.
The scaling group, Classic Load Balancer (CLB) instances to be associated, and ApsaraDB RDS instances to be associated must be in the same region. CLB instances are formerly known as Server Load Balancer (SLB) instances. For more information, see Regions and zones.
If you associate a CLB instance when you create a scaling group, Auto Scaling automatically adds ECS instances in the scaling group to the backend server group of the associated CLB instance. You can specify a server group to which ECS instances can be added. You can add ECS instances to the following types of server groups:
- Default server group: a group of ECS instances that are used to receive requests. If you do not specify a vServer group or a primary/secondary server group for a listener, requests are forwarded to the ECS instances in the default server group.
-
vServer group: If you want to forward requests to different backend servers or configure domain name- or URL-based routing methods, you can use vServer groups.Note If you specify the default server group and multiple vServer groups at the same time, ECS instances are added to all the specified server groups.
The default weight of an ECS instance added to the backend server group of a CLB instance is 50. The CLB instance must meet the following requirements:
- The CLB instance must be in the Active state. You can call the DescribeLoadBalancers operation to query the status of the specified CLB instance.
- Health check must be enabled on all listener ports configured for the CLB instance. Otherwise, the scaling group fails to be created.
If you associate an Application Load Balancer (ALB) server group with a scaling group, Auto Scaling automatically adds ECS instances that are added to the scaling group to the ALB server group as backend servers to process access requests distributed by the ALB instance to which the ALB server group belongs. You can specify multiple ALB server groups, but the server groups must belong to the same virtual private cloud (VPC) as the scaling group. For more information, see AttachAlbServerGroups.
If you associate an ApsaraDB RDS instance when you create a scaling group, Auto Scaling automatically adds the internal IP addresses of the ECS instances that are added to the scaling group to the whitelist of the associated ApsaraDB RDS instance. The ApsaraDB RDS instance must meet the following requirements:
- The ApsaraDB RDS instance must be in the Running state. You can call the DescribeDBInstances operation to query the status of the specified ApsaraDB RDS instance.
- The number of IP addresses in the whitelist of the ApsaraDB RDS instance cannot exceed the upper limit. For more information, see Configure a whitelist in the ApsaraDB RDS documentation.
If the MultiAZPolicy parameter of a scaling group is set to COST_OPTIMIZED, the following rules apply:
- You can use the OnDemandBaseCapacity, OnDemandPercentageAboveBaseCapacity, and SpotInstancePools parameters to specify the percentages of pay-as-you-go instances and preemptible instances based on the cost optimization policy. This instance allocation method is prioritized during scaling.
- When OnDemandBaseCapacity, OnDemandPercentageAboveBaseCapacity, or SpotInstancePools is not specified, the instance types available at the lowest cost are used to create instances based on the cost optimization policy.
Debugging
Request parameters
Parameter | Type | Required | Example | Description |
---|---|---|---|---|
Action | String | Yes | CreateScalingGroup |
The operation that you want to perform. Set the value to CreateScalingGroup. |
ScalingGroupName | String | No | scalinggroup**** |
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. The default value is the value of ScalingGroupId. |
LaunchTemplateId | String | No | lt-m5e3ofjr1zn1aw7**** |
The ID of the launch template that is used by Auto Scaling to create instances. |
LaunchTemplateVersion | String | No | Default |
The version number of the launch template. Valid values:
|
InstanceId | String | No | i-28wt4**** |
The ID of the ECS instance from which Auto Scaling obtains configuration information and uses this information to create a scaling configuration. |
RegionId | String | Yes | cn-qingdao |
The ID of the region where the scaling group resides. For more information, see Regions and zones. |
MinSize | Integer | Yes | 2 |
The minimum number of ECS instances in the scaling group. When the number of existing ECS instances in the scaling group is less than the MinSize value, Auto Scaling automatically creates ECS instances until the number of instances is equal to the MinSize value. Note The value of MinSize must be less than or equal to the value of MaxSize.
|
MaxSize | Integer | Yes | 20 |
The maximum number of ECS instances in the scaling group. When the number of existing ECS instances in the scaling group is greater than the MaxSize value, Auto Scaling automatically removes ECS instances until the number of instances is equal to the MaxSize value. The value range of MaxSize depends on your usage of Auto Scaling. You can go to the Quota Center to check 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 value range of MaxSize is 0 to 2000. |
DefaultCooldown | Integer | No | 300 |
The cooldown time after a scale-in or scale-out activity is executed. Valid values: 0 to 86400. Unit: seconds. During the cooldown time, Auto Scaling executes only scaling activities that are triggered by CloudMonitor event-triggered tasks. Default value: 300. |
LoadBalancerIds | String | No | ["lb-bp1u7etiogg38yvwz****", "lb-bp168cqrux9ai9l7f****", "lb-bp1jv3m9zvj22ufxp****"] |
The IDs of CLB instances. CLB instances are formerly known as SLB instances. The value can be a JSON array that contains multiple CLB instance IDs. Separate multiple IDs with commas (,). The number of CLB instances that can be associated with a scaling group depends on your usage of Auto Scaling. You can go to the Quota Center to check the quota of SLB Instances That Can Be Associated with a Scaling Group. |
DBInstanceIds | String | No | ["rm-bp142f86de0t7****", "rm-bp18l1z42ar4o****", "rm-bp1lqr97h4aqk****"] |
The IDs of ApsaraDB RDS instances. The value can be a JSON array that contains multiple ApsaraDB RDS instance IDs. Separate multiple IDs with commas (,). The number of ApsaraDB RDS instances that can be associated with a scaling group depends on your usage of Auto Scaling. You can go to the Quota Center to check the quota of ApsaraDB RDS Instances That Can Be Associated with a Scaling Group. |
RemovalPolicy.1 | String | No | OldestScalingConfiguration |
Specifies the first step for the instance removing policy. Valid values:
Note The scaling configuration mentioned in OldestScalingConfiguration refers to the instance
configuration source of a scaling group, which can be a scaling configuration or a
launch template.
The version of a launch template does not indicate the sequence in which the template is added. For example, you use the lt-foress V2 template to create a scaling group, and then you replace the template with the lt-foress V1 template when you modify the scaling group. In this case, the scaling group considers the lt-foress V2 launch template as the earliest template. The default value of RemovalPolicy.1 is used only when both RemovalPolicy.1 and RemovalPolicy.2 are not specified. Default value: OldestScalingConfiguration. Note The removal of ECS instances from a scaling group is also affected by the scaling
policy (MultiAZPolicy) specified for the scaling group. For more information, see
Configure a combination policy for removing instances.
|
RemovalPolicy.2 | String | No | OldestInstance |
Specifies the second step for the instance removing policy. This parameter value cannot be the same as the RemovalPolicy.1 value. Valid values:
The default value of RemovalPolicy.2 is used only when both RemovalPolicy.1 and RemovalPolicy.2 are not specified. Default value: OldestInstance. Note The removal of ECS instances from a scaling group is also affected by the scaling
policy (MultiAZPolicy) specified for the scaling group. For more information, see
Configure a combination policy for removing instances.
|
VSwitchId | String | No | vsw-bp14zolna43z266bq**** |
The ID of the vSwitch. If VSwitchId is specified, the network type of the scaling group is VPC. Note If VSwitchId or VSwitchIds.N is not specified, the network type of the scaling group
is classic network.
|
MultiAZPolicy | String | No | PRIORITY |
The ECS instance scaling policy for a multi-zone scaling group. Valid values:
|
HealthCheckType | String | No | ECS |
Specifies whether to perform health checks on instances in the scaling group. Valid values:
Default value: ECS. |
ScalingPolicy | String | No | recycle |
The reclaim mode of the scaling group. Valid values:
ScalingPolicy specifies the reclaim modes of scaling groups, but the policy that is used to remove ECS instances from scaling groups is determined by the RemovePolicy parameter of the RemoveInstances operation. For more information, see RemoveInstances. |
ClientToken | String | No | 123e4567-e89b-12d3-a456-42665544**** |
The client token that is used to ensure the idempotence of the request. You can use the client to generate the value, but you must ensure that it is unique among different requests. The token can only contain ASCII characters and cannot exceed 64 characters in length. For more information, see Ensure idempotence. |
OnDemandBaseCapacity | Integer | No | 30 |
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. |
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 pay-as-you-go instances reaches the value for the OnDemandBaseCapacity parameter. Valid values: 0 to 100. |
SpotInstanceRemedy | Boolean | No | true |
Specifies whether to supplement preemptible instances. If this parameter is set to true, Auto Scaling attempts to create 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 requirements on the number of instances when the expected capacity of preemptible instances cannot be fulfilled due to reasons such as high prices or insufficient resources. This parameter takes effect only when MultiAZPolicy is set to COST_OPTIMIZED. Valid values:
Default value: true. |
SpotInstancePools | Integer | No | 5 |
The number of instance types that are available. The system creates preemptible instances of multiple instance types that are available at the lowest cost in the scaling group. Valid values: 1 to 10. |
DesiredCapacity | Integer | No | 5 |
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 MaxSize value and cannot be less than the MinSize value. |
GroupDeletionProtection | Boolean | No | true |
Specifies whether to enable deletion protection for the scaling group. Valid values:
Default value: false. |
GroupType | String | No | ECS |
The type of instances that are managed by the scaling group. Valid values:
Default value: ECS. |
ContainerGroupId | String | No | eci-uf6fonnghi50u374**** |
The ID of the elastic container instance. |
VSwitchIds.N | String | No | vsw-bp14zolna43z266bq**** |
The ID of vSwitch N. Valid values of N: 1 to 5. If you use the VSwitchIds.N parameter, the VSwitchId parameter is ignored. If VSwitchId is specified, the network type of the scaling group is VPC. When you specify multiple vSwitches, take note of the following items:
Note If VSwitchId or VSwitchIds.N is not specified, the network type of the scaling group
is classic network.
|
LifecycleHook.N.DefaultResult | String | No | CONTINUE |
The action that the scaling group takes when the lifecycle hook times out. Valid values:
If the scaling group has multiple lifecycle hooks and one of them times out when the DefaultResult parameter is set to ABANDON during a scale-in activity, the remaining lifecycle hooks in the scaling group also time out. Otherwise, the scaling activity proceeds as expected after the lifecycle hook times out and continues with the action specified by the DefaultResult parameter. Default value: CONTINUE. |
LifecycleHook.N.LifecycleHookName | String | No | lifecyclehook**** |
The name of lifecycle hook N. After you specify this parameter, you cannot modify the name of the lifecycle hook. If you do not specify this parameter, the name of the lifecycle hook is the same as the ID of the lifecycle hook. |
LifecycleHook.N.LifecycleTransition | String | No | SCALE_OUT |
The type of scaling activities to which the lifecycle hook applies. Valid values:
Note If lifecycle hooks are specified for the scaling group, LifecycleHook.N.LifecycleTransition
is required and other related parameters are optional.
|
LifecycleHook.N.NotificationMetadata | String | No | Test |
The fixed string to be included when Auto Scaling sends a notification about the wait state of a scaling activity. The parameter value cannot exceed 128 characters in length. Auto Scaling sends the specified NotificationMetadata parameter value together with the notification message. This way, you can categorize your notifications. The LifecycleHook.N.NotificationMetadata parameter is valid only after you specify the LifecycleHook.N.NotificationArn parameter. |
LifecycleHook.N.NotificationArn | String | No | acs:ess:cn-hangzhou:1111111111:queue/queue2 |
The Alibaba Cloud Resource Name (ARN) of the notification object that Auto Scaling uses to notify you when an instance enters the pending state for the lifecycle hook. This object can be a Message Service (MNS) queue or an MNS topic. The parameter value is in the following format: acs:ess:{region}:{account-id}:{resource-relative-id}.
Examples:
|
LifecycleHook.N.HeartbeatTimeout | Integer | No | 600 |
The period of time before the lifecycle hook times out. When the lifecycle hook times out, Auto Scaling performs the default action. Valid values: 30 to 21600. Unit: seconds. After you create a lifecycle hook, you can call the RecordLifecycleActionHeartbeat operation to extend the timeout period and keep the instances in the pending state. You can also call the CompleteLifecycleAction operation to remove a scaling activity from the pending state. Default value: 600. |
VServerGroup.N.VServerGroupAttribute.N.VServerGroupId | String | No | rsp-bp1443g77**** |
The ID of the vServer group. For more information, see AttachVServerGroups. |
VServerGroup.N.VServerGroupAttribute.N.Weight | Integer | No | 100 |
The weight of the ECS instance as a backend server after the instance is added to vServer group N. If you increase the weight of an ECS instance in a vServer group, the number of access requests that are forwarded to the ECS instance increases. If the weight is set to 0, no access requests are forwarded to the ECS instance. Valid values: 0 to 100. Default value: 50. Valid values of N: 1 to 5. For more information, see AttachVServerGroups. |
VServerGroup.N.VServerGroupAttribute.N.Port | Integer | No | 22 |
The port number used by the ECS instance after the instance is added to vServer group N. Valid values: 1 to 65535. For more information, see AttachVServerGroups. |
VServerGroup.N.LoadBalancerId | String | No | lb-bp1u7etiogg38yvwz**** |
The ID of the CLB instance to which vServer group N belongs. CLB instances are formerly known as SLB instances. For more information, see AttachVServerGroups. |
Tag.N.Key | String | No | Department |
The key of tag N of the scaling group. |
Tag.N.Value | String | No | Finance |
The value of tag N of the scaling group. |
LaunchTemplateOverride.N.InstanceType | String | No | ecs.c5.xlarge |
If you want to scale instances in the scaling group based on the capacity, you must specify both the LaunchTemplateOverride.N.InstanceType and LaunchTemplateOverride.N.WeightedCapacity parameters. This parameter specifies instance type N that overrides the instance type specified in the launch template. You can specify N instance types for the extended configurations. 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 capacity, you must specify the LaunchTemplateOverride.N.WeightedCapacity parameter after the LaunchTemplateOverride.N.InstanceType parameter is specified. The two parameters have a one-to-one correspondence. The value 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 greater weight indicates 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:
To meet the expected capacity, Auto Scaling creates two ecs.c5.xlarge instances. Note The capacity of the scaling group cannot exceed the sum of the maximum capacity specified
by MaxSize and the maximum weight of the instance type.
Valid values of WeightedCapacity in InstanceTypeOverride.N.WeightedCapacity: 1 to 500. |
AlbServerGroup.N.AlbServerGroupId | String | No | sgp-ddwb0y0g6y9bjm**** |
The ID of the ALB server group. N indicates the serial number of the ALB server group. You can associate only a limited number of ALB server groups with a scaling group. To view or manually request a quota increase, go to the Quota Center. |
AlbServerGroup.N.Weight | Integer | No | 100 |
The weight of the ECS instance as a backend server after the instance is added to the ALB server group. If you increase the weight of an ECS instance, the number of access requests that are forwarded to the ECS instance increases. If the weight is set to 0, no access requests are forwarded to the ECS instance. Valid values: 0 to 100. N indicates the serial number of the ALB server group. |
AlbServerGroup.N.Port | Integer | No | 22 |
The port number used by the ECS instance after the instance is added to ALB server group N. Valid values: 1 to 65535. N indicates the serial number of the ALB server group. Note If the N values are the same, but the port numbers are different, the system associates
the ALB server group with these ports in the scaling group.
|
Response parameters
Parameter | Type | Example | Description |
---|---|---|---|
RequestId | String | 473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E |
The ID of the request. |
ScalingGroupId | String | asg-bp14wlu85wrpchm0**** |
The ID of the scaling group. |
Examples
Sample requests
http(s)://ess.aliyuncs.com/?Action=CreateScalingGroup
&AlbServerGroup.1.AlbServerGroupId=sgp-ddwb0y0g6y9bjm****
&AlbServerGroup.1.Port=22
&AlbServerGroup.1.Weight=100
&MaxSize=20
&MinSize=2
&RegionId=cn-qingdao
&<Common request parameters>
Sample success responses
XML
format
HTTP/1.1 200 OK
Content-Type:application/xml
<CreateScalingGroupResponse>
<RequestId>473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E</RequestId>
<ScalingGroupId>asg-bp14wlu85wrpchm0****</ScalingGroupId>
</CreateScalingGroupResponse>
JSON
format
HTTP/1.1 200 OK
Content-Type:application/json
{
"RequestId" : "473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E",
"ScalingGroupId" : "asg-bp14wlu85wrpchm0****"
}
Error codes
For a list of error codes, visit the API Error Center.
HTTP status code |
Error code |
Error message |
Description |
---|---|---|---|
400 |
IncorrectDBInstanceStatus |
The current status of DB instance "XXX" does not support this action. |
The error message returned because the specified ApsaraDB RDS instance is not in the Running state. |
400 |
IncorrectLoadBalancerHealthCheck |
The current health check type of specified load balancer does not support this action. |
The error message returned because the health check feature is not enabled for the specified CLB instance. |
400 |
IncorrectLoadBalancerStatus |
The current status of the specified load balancer does not support this action. |
The error message returned because the specified CLB instance is not in the Active state. |
400 |
IncorrectVSwitchStatus |
The current status of virtual switch does not support this operation. |
The error message returned because the vSwitch is unavailable and ECS instances cannot be created. |
400 |
InvalidDBInstanceId. RegionMismatch |
DB instance "XXX" and the specified scaling group are not in the same Region. |
The error message returned because the specified ApsaraDB RDS instance and the specified scaling group are not in the same region. |
400 |
InvalidLoadBalancerId.IncorrectAddressType |
The current address type of specified load balancer does not support this action. |
The error message returned because the network type of the specified CLB instance does not match the network type of the vSwitch. |
400 |
InvalidLoadBalancerId.IncorrectInstanceNetworkType |
The network type of the instance in specified Load Balancer does not support this action. |
The error message returned because the network type of the ECS instance added to the backend server group of the specified CLB instance is different from the network type of the scaling group. |
400 |
InvalidLoadBalancerId.RegionMismatch |
The specified Load Balancer and the specified scaling group are not in the same Region. |
The error message returned because the specified CLB instance and the specified scaling group are not in the same region. |
400 |
InvalidLoadBalancerId.VPCMismatch |
The specified virtual switch and the instance in specified Load Balancer are not in the same VPC. |
The error message returned because the vSwitch and the ECS instance added to the backend server group of the CLB instance associated with the scaling group are not in the same VPC. |
400 |
InvalidParameter |
The specified value of parameter "ScalingPolicy" is not valid. |
The error message returned because the specified ScalingPolicy parameter does not exist. |
400 |
InvalidParameter.Conflict |
The value of parameter <parameter name> and parameter <parameter name> are conflict. |
The error message returned because the specified MinSize value is greater than the MaxSize value. |
400 |
InvalidScalingGroupName.Duplicate |
The specified value of parameter <parameter name> is duplicated. |
The error message returned because the specified scaling group name already exists. |
400 |
QuotaExceeded.DBInstanceSecurityIP |
Security IP quota exceeded in DB instance "XXX". |
The error message returned because the maximum number of IP addresses in the whitelist that manages access to the associated ApsaraDB RDS instance has been reached. |
400 |
QuotaExceeded.PrivateIpAddress |
Private IP address quota exceeded in the specified virtual switch. |
The error message returned because no idle private IP addresses are available in the CIDR block of the vSwitch. |
400 |
QuotaExceeded.ScalingGroup |
Scaling group quota exceeded. |
The error message returned because the maximum number of scaling groups has been reached. |
400 |
QuotaExceeded.VPCInstance |
Instance quota exceeded in the specified VPC. |
The error message returned because the maximum number of instances in the VPC has been reached. |
404 |
InvalidDBInstanceId.NotFound |
DB instance "XXX" does not exist. |
The error message returned because the specified ApsaraDB RDS instance does not exist. |
404 |
InvalidLoadBalancerId.NotFound |
The specified Load Balancer does not exist. |
The error message returned because the specified CLB instance does not exist. |
404 |
InvalidRegionId.NotFound |
The specified region does not exist. |
The error message returned because the specified region does not exist. |
404 |
InvalidVSwitchId.NotFound |
The specified virtual switch does not exist. |
The error message returned because the specified vSwitch does not exist. |
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 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 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 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. |
400 |
AlbServerGroup.NotExist |
The ServerGroup "%s" do(es) not exist. |
The error message returned because the specified ALB server group does not exist within the account. |