All Products
Search
Document Center

Auto Scaling:CreateScalingGroup

更新时间:Dec 15, 2025

You can call the CreateScalingGroup operation to create a scaling group. A scaling group automatically adjusts your computing capacity, which is the number of instances, based on your business needs and policies.

Usage notes

A scaling group is a collection of Elastic Compute Service (ECS) instances that are used in the same application scenario.

The number of scaling groups that you can create in a region depends on your Auto Scaling usage. To view your quota for the total number of scaling groups, go to Quota Center.

A scaling group does not take effect immediately after it is created. You must call the EnableScalingGroup operation to enable the scaling group. After the scaling group is enabled, it can trigger scaling activities and execute scaling rules.

The scaling group, its associated Classic Load Balancer (CLB) (formerly SLB) instances, and its associated RDS instances must be in the same region. For more information, see Regions and zones.

If you associate a CLB instance with a scaling group, Auto Scaling automatically adds the ECS instances in the scaling group to the backend server groups of the CLB instance. You can specify the server groups to which the ECS instances are added. Default server groups and vServer groups are supported. The following types of server groups are supported:

Note

If you specify the default server group and multiple vServer groups at the same time, ECS instances are added to all specified server groups.

  • Default server group: This is a group of ECS instances that receive frontend requests. If a listener is not configured with a vServer group or a primary/secondary server group, requests are forwarded to the ECS instances in the default server group.

  • vServer group: You can use vServer groups to forward different requests to different backend servers, or to forward requests based on domain names and URLs.

After an ECS instance is added to a backend server group of a CLB instance, its weight is 50 by default. 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 status of the CLB instance.

  • Health checks must be enabled for all listener ports that are configured for the CLB instance. Otherwise, the scaling group cannot be created.

If you associate an Application Load Balancer (ALB) server group or a Network Load Balancer (NLB) server group with a scaling group, Auto Scaling automatically adds the ECS instances in the scaling group as backend servers to the specified server group. These servers process access requests that are distributed by the ALB or NLB instance. You can specify multiple ALB or NLB server groups, but they must be in the same VPC as the scaling group. For more information, see AttachAlbServerGroups or AttachServerGroups.

If you associate an RDS instance with a scaling group, Auto Scaling automatically adds the private IP addresses of the ECS instances in the scaling group to the access 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 status of the RDS instance.

  • The number of IP addresses in the access whitelist of the RDS instance cannot exceed the upper limit. For more information, see the RDS document about setting whitelists.

If you set the MultiAZPolicy of the scaling group to COST_OPTIMIZED:

  • If you specify the OnDemandBaseCapacity, OnDemandPercentageAboveBaseCapacity, and SpotInstancePools parameters, these parameters define the instance allocation method for the cost optimization policy. This allocation method is prioritized during scale-outs and scale-ins.

  • If you do not specify the OnDemandBaseCapacity, OnDemandPercentageAboveBaseCapacity, or SpotInstancePools parameters, instances are created based on the lowest cost as determined by the cost optimization policy.

If you configure propagatable tags for the scaling group, which means Tag.N.Propagate is set to true:

  • The tags of the scaling group are propagated only to newly created instances, not to instances that are already running in the scaling group.

  • If you specify instance tags in the scaling configuration and choose to propagate the tags of the scaling group to the instances, all tags are applied to the instances.

  • If a tag in the scaling configuration has the same key as a propagatable tag of the scaling group, the tag value from the scaling configuration takes precedence.

Try it now

You can call this operation in OpenAPI Explorer. This eliminates the need to calculate signatures. After a successful call, OpenAPI Explorer automatically generates SDK code examples.

Request parameters

Parameter

Type

Required

Example

Description

Action

String

Yes

CreateScalingGroup

A required parameter. Set the value to CreateScalingGroup.

ScalingGroupName

String

No

scalinggroup****

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 digit, an uppercase or lowercase letter, or a Chinese character. It can contain digits, underscores (_), hyphens (-), and periods (.).

If you do not specify this parameter, the value of ScalingGroupId is used by default.

LaunchTemplateId

String

No

lt-m5e3ofjr1zn1aw7****

The ID of the launch template that provides the launch configurations for the scaling group.

LaunchTemplateVersion

String

No

Default

The version of the launch template. Valid values:

  • A fixed template version number.

  • Default: The default version of the template is always used.

  • Latest: The latest version of the template is always used.

InstanceId

String

No

i-28wt4****

The ID of the instance. When you create a scaling group, the system obtains the required configuration information from the specified instance and automatically creates a scaling configuration.

RegionId

String

Yes

cn-qingdao

The ID of the region where the scaling group is located. For more information, see Regions and zones.

MinSize

Integer

Yes

2

The minimum number of instances in the scaling group. Auto Scaling automatically creates instances if the number of instances in the scaling group is less than the value of MinSize.

Note

MinSize must be less than or equal to the value of MaxSize.

MaxSize

Integer

Yes

20

The maximum number of instances in the scaling group. Auto Scaling automatically removes instances if the number of instances in the scaling group is greater than the value of MaxSize.

The value range of MaxSize depends on your Auto Scaling usage. To view your quota for the maximum number of instances in a single scaling group, go to Quota Center.

If your quota for the maximum number of instances in a single scaling group is 2,000, the value range for MaxSize is 0 to 2,000.

DefaultCooldown

Integer

No

300

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

During the cooldown period, the scaling group does not execute other scaling activities. This parameter is effective only for scaling activities that are triggered by event-triggered tasks.

Default value: 300.

LoadBalancerIds

String

No

["lb-bp1u7etiogg38yvwz****", "lb-bp168cqrux9ai9l7f****", "lb-bp1jv3m9zvj22ufxp****"]

The IDs of Classic Load Balancer (CLB) (formerly SLB) instances. You can specify multiple CLB instance IDs in a JSON array. Separate the IDs with commas (,).

The total number of CLB instances that can be associated with a single scaling group depends on your Auto Scaling usage. To view your quota for the total number of SLB instances that can be associated with a single scaling group, go to Quota Center.

DBInstanceIds

String

No

["rm-bp142f86de0t7****", "rm-bp18l1z42ar4o****", "rm-bp1lqr97h4aqk****"]

The IDs of RDS instances. You can specify multiple RDS instance IDs in a JSON array. Separate the IDs with commas (,).

The total number of RDS instances that can be associated with a single scaling group depends on your Auto Scaling usage. To view your quota for the total number of RDS instances that can be associated with a single scaling group, go to Quota Center.

RemovalPolicy.1

String

No

OldestScalingConfiguration

The first policy for removing instances from the scaling group. This value cannot be the same as the values of RemovalPolicy.2 and RemovalPolicy.3. Valid values:

  • OldestInstance: Removes the ECS instance that was added to the scaling group earliest.

  • NewestInstance: Removes the ECS instance that was added to the scaling group most recently.

  • OldestScalingConfiguration: Removes the ECS instance that was created from the earliest scaling configuration.

  • CustomPolicy: Removes ECS instances based on a custom scale-in policy (Function).

The scaling configuration mentioned in OldestScalingConfiguration refers to the source of the instance configuration in the group, including scaling configurations and launch templates. CustomPolicy can be set only as the first removal policy. If you set this parameter to CustomPolicy, you must also specify the CustomPolicyARN parameter.

Note

The removal of ECS instances from a scaling group is also affected by the scale-in and scale-out policy (MultiAZPolicy) of the scaling group. For more information, see Configure a combination of instance removal policies.

RemovalPolicy.2

String

No

OldestInstance

The second policy for removing instances from the scaling group. This value cannot be the same as the values of RemovalPolicy.1 and RemovalPolicy.3. Valid values:

  • OldestInstance: Removes the ECS instance that was added to the scaling group earliest.

  • NewestInstance: Removes the ECS instance that was added to the scaling group most recently.

  • OldestScalingConfiguration: Removes the ECS instance that was created from the earliest scaling configuration.

Note

The removal of ECS instances from a scaling group is also affected by the scale-in and scale-out policy (MultiAZPolicy) of the scaling group. For more information, see Configure a combination of instance removal policies.

RemovalPolicy.3

String

No

NewestInstance

The third policy for removing instances from the scaling group. This value cannot be the same as the values of RemovalPolicy.1 and RemovalPolicy.2. Valid values:

  • OldestInstance: Removes the ECS instance that was added to the scaling group earliest.

  • NewestInstance: Removes the ECS instance that was added to the scaling group most recently.

  • OldestScalingConfiguration: Removes the ECS instance that was created from the earliest scaling configuration.

Note

The removal of ECS instances from a scaling group is also affected by the scale-in and scale-out policy (MultiAZPolicy) of the scaling group. For more information, see Configure a combination of instance removal policies.

VSwitchId

String

No

vsw-bp14zolna43z266bq****

The ID of the vSwitch. If you specify this parameter, the network type of the scaling group is VPC.

Note

If you do not specify the VSwitchId or VSwitchIds.N parameter, the network type of the scaling group is classic network by default.

MultiAZPolicy

String

No

PRIORITY

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

  • PRIORITY: The vSwitch that is specified first by VSwitchIds.N has the highest priority. Auto Scaling preferentially scales instances in the zone where the vSwitch with the highest priority is located. If the scaling fails, Auto Scaling automatically scales instances in the zone where the vSwitch with the next highest priority is located.

  • COST_OPTIMIZED: During a scale-out, Auto Scaling creates ECS instances in ascending order of vCPU unit price. During a scale-in, Auto Scaling removes ECS instances in descending order of vCPU unit price. If the scaling configuration specifies multiple instance types with a preemptible billing method, preemptible instances are preferentially created. You can use the CompensateWithOnDemand parameter to specify whether to automatically create pay-as-you-go instances if preemptible instances cannot be created due to reasons such as insufficient inventory.

    Note

    COST_OPTIMIZED takes effect only when multiple instance types are specified in the scaling configuration or spot instances are used.

  • BALANCE: ECS instances are evenly distributed across the zones that are specified for the scaling group. If the zones become imbalanced due to reasons such as insufficient inventory, you can call the RebalanceInstance operation to rebalance the resources.

  • COMPOSABLE: A composite policy. You can combine the preceding policies as needed. You can also specify additional parameters to finely control the capacity of the scaling group.

Default value: PRIORITY.

HealthCheckType

String

No

ECS

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

  • NONE: No health checks are performed.

  • ECS: Health checks are performed on instances in the scaling group. This value enables instance health checks for both ECS and ECI scaling groups.

  • LOAD_BALANCER: The health status of an instance is determined by the health check results of the associated load balancer. This option does not support CLB.

Default value: ECS.

Note

If you want to enable both instance health checks and load balancer health checks, use the HealthCheckTypes parameter.

ScalingPolicy

String

No

recycle

The reclaim mode of the scaling group. Valid values:

  • recycle: The scaling group is in economical mode.

  • release: The scaling group is in release mode.

  • forcerelease: The scaling group is in forced release mode.

    Note

    If you set this parameter to forcerelease, the system forcibly releases `Running` instances during a scale-in. A forced release is equivalent to a power-off operation. Data in the memory and ephemeral storage of the instance is erased and cannot be recovered. Use this option with caution.

  • forcerecycle: The scaling group is in forced economical mode.

    Note

    If you set this parameter to forcerecycle, the system forcibly shuts down `Running` instances during a scale-in. A forced shutdown is equivalent to a power-off operation. Data in the memory and ephemeral storage of the instance is erased and cannot be recovered. Use this option with caution.

ScalingPolicy specifies the reclaim mode of the scaling group. However, the specific action taken when an instance is removed from the scaling group is determined by the RemovePolicy parameter of the RemoveInstances operation. For more information, see RemoveInstances.

ClientToken

String

No

123e4567-e89b-12d3-a456-42665544****

A client token to ensure the idempotence of the request.

Generate a parameter value from your client to make sure that the value is unique among different requests. This parameter can contain only ASCII characters and cannot exceed 64 characters in length. For more information, see How to ensure idempotence.

OnDemandBaseCapacity

Integer

No

30

The minimum number of pay-as-you-go instances that are required for the scaling group. Valid values: 0 to 1000. If the number of pay-as-you-go instances is less than this value, Auto Scaling preferentially creates pay-as-you-go instances.

When the MultiAZPolicy parameter is set to COMPOSABLE, the default value is 0.

OnDemandPercentageAboveBaseCapacity

Integer

No

20

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

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

SpotInstanceRemedy

Boolean

No

true

Specifies whether to enable supplementation of spot instances. If this parameter is set to true, Auto Scaling creates a new instance to replace a spot instance that is about to be reclaimed.

CompensateWithOnDemand

Boolean

No

true

This parameter takes effect only when MultiAZPolicy is set to COST_OPTIMIZED. It specifies whether to allow automatic creation of pay-as-you-go instances to meet the required number of ECS instances if spot instances cannot be created due to reasons such as price or insufficient inventory. Valid values:

  • true: Yes.

  • false: No.

Default value: true.

SpotInstancePools

Integer

No

5

The number of instance types that you can specify. The scaling group creates spot instances of the specified instance types in a balanced manner and at the lowest cost. Valid values: 1 to 10.

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

DesiredCapacity

Integer

No

5

The expected number of ECS instances in the scaling group. Auto Scaling automatically maintains the number of ECS instances at the expected value. The value of this parameter must be less than or equal to MaxSize and greater than or equal to MinSize.

GroupDeletionProtection

Boolean

No

true

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

  • true: Enables deletion protection for the scaling group. The scaling group cannot be deleted.

  • false: Disables deletion protection for the scaling group.

Default value: false.

GroupType

String

No

ECS

The type of instances that are managed by the scaling group. Valid values:

  • ECS: The scaling group manages ECS instances.

  • ECI: The scaling group manages ECI instances.

Default value: ECS.

ContainerGroupId

String

No

eci-uf6fonnghi50u374****

The ID of the ECI instance, which is the container group ID.

VSwitchIds.N

String

No

vsw-bp14zolna43z266bq****

The IDs of one or more vSwitches. If you specify this parameter, the VSwitchId parameter is ignored. If you specify this parameter, the network type of the scaling group is VPC.

If you specify multiple vSwitches:

  • They must belong to the same VPC.

  • They can belong to different zones.

  • The priority of the vSwitches is sorted in ascending order of the number N. 1 indicates the highest priority. When it is not possible to create ECS instances in the zone of the vSwitch with a higher priority, the system automatically selects the vSwitch with the next highest priority to create ECS instances.

Note

If you do not specify the VSwitchId or VSwitchIds.N parameter, the network type of the scaling group is classic network by default.

LifecycleHook.N.DefaultResult

String

No

CONTINUE

The action to take after the wait state ends. Valid values:

  • CONTINUE: Continues to respond to the scale-out or scale-in activity.

  • ABANDON: Directly releases the ECS instances created during the scale-out activity or removes the ECS instances from the scaling group during the scale-in activity.

If a scale-in (SCALE_IN) activity triggers multiple lifecycle hooks, and one of them has DefaultResult set to ABANDON, the other wait states end when the wait state for that hook ends. In all other cases, the next action is based on the action of the last wait state to end.

Default value: CONTINUE.

LifecycleHook.N.LifecycleHookName

String

No

lifecyclehook****

The name of the lifecycle hook. The name cannot be modified after you specify it. If you do not specify this parameter, the ID of the lifecycle hook is used by default.

LifecycleHook.N.LifecycleTransition

String

No

SCALE_OUT

The type of scaling activity to which the lifecycle hook applies. Valid values:

  • SCALE_OUT: a scale-out activity.

  • SCALE_IN: a scale-in activity.

Note

If you specify a lifecycle hook for the scaling group, this parameter is required. Other related parameters are optional.

LifecycleHook.N.NotificationMetadata

String

No

Test

The fixed string of information for the wait state of a scaling activity. The value of this parameter cannot exceed 128 characters in length. When Auto Scaling sends a message to a notification recipient, it includes the value of this parameter. This helps you manage and categorize notifications. This parameter takes effect only when you specify the NotificationArn parameter.

LifecycleHook.N.NotificationArn

String

No

acs:ess:cn-hangzhou:1111111111:queue/queue2

The Alibaba Cloud Resource Name (ARN) of the notification recipient for the lifecycle hook. You can specify a Simple Message Queue (formerly MNS) queue or topic. The ARN must be in the following format: acs:ess:{region}:{account-id}:{resource-relative-id}.

  • region: the region where the scaling group is located.

  • account-id: the Alibaba Cloud account ID.

Examples:

  • MNS queue: acs:ess:{region}:{account-id}:queue/{queuename}.

  • MNS topic: acs:ess:{region}:{account-id}:topic/{topicname}.

LifecycleHook.N.HeartbeatTimeout

Integer

No

600

The wait time of 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 RecordLifecycleActionHeartbeat to extend the wait time of an ECS instance, or call CompleteLifecycleAction to end the wait state of the scaling activity ahead of schedule.

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

After Auto Scaling adds an instance to a vServer group, this is the weight of the instance as a backend server. A higher weight means the instance is allocated more access requests. If the weight is 0, the instance does not receive access requests. Valid values: 0 to 100. Default value: 50.

For more information, see AttachVServerGroups.

VServerGroup.N.VServerGroupAttribute.N.Port

Integer

No

22

After Auto Scaling adds an instance to a vServer group, this is the port number used by the instance. Valid values: 1 to 65535.

For more information, see AttachVServerGroups.

VServerGroup.N.LoadBalancerId

String

No

lb-bp1u7etiogg38yvwz****

The ID of the CLB (formerly SLB) instance to which the vServer group belongs.

For more information, see AttachVServerGroups.

Tag.N.Key

String

No

Department

The key of the tag for the scaling group.

Tag.N.Value

String

No

Finance

The value of the tag for the scaling group.

Tag.N.Propagate

Boolean

No

false

Indicates whether the tag can be propagated. Valid values:

  • true: The tags of the scaling group are propagated only to newly created instances, not to instances that are already running in the scaling group.

  • false: The tags of the scaling group are not propagated to instances.

Default value: false.

LaunchTemplateOverride.N.InstanceType

String

No

ecs.c5.xlarge

If you want the scaling group to scale instances based on the capacity of instance types, specify both this parameter and LaunchTemplateOverride.N.WeightedCapacity.

This parameter specifies an instance type that is used to override the instance type in the launch template. You can specify N values for this parameter to support N instance types. N specifies the number of instance types. Valid values of N: 1 to 20.

Note

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

For the valid values of InstanceType, see Instance families.

LaunchTemplateOverride.N.WeightedCapacity

Integer

No

4

If you want the scaling group to scale instances based on the capacity of instance types, specify this parameter after you specify LaunchTemplateOverride.N.InstanceType. The values of N for these two parameters must be the same.

This parameter specifies the weight of the instance type. The weight indicates the capacity of a single instance of the specified instance type in the scaling group. A higher weight indicates that a smaller number of instances of the specified instance type are required to meet the expected capacity.

Because performance metrics such as the number of vCPUs and memory size vary for each instance type, you can configure different weights for different instance types based on your needs.

Example:

  • Current capacity: 0

  • Expected capacity: 6

  • ecs.c5.xlarge capacity: 4

To meet the expected capacity, the scaling group will scale out two ecs.c5.xlarge instances.

Note

During a scale-out, the capacity of the scaling group cannot exceed the sum of the maximum capacity (MaxSize) and the maximum weight of an instance type.

Valid values for WeightedCapacity: 1 to 500.

LaunchTemplateOverride.N.SpotPriceLimit

Float

No

0.025

The maximum bid price for the instance type that is specified by LaunchTemplateOverride.N.InstanceType. You can specify N values for this parameter to support N instance types. N specifies the number of instance types. Valid values of N: 1 to 20.

Note

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

AlbServerGroup.N.AlbServerGroupId

String

No

sgp-ddwb0y0g6y9bjm****

The ID of the ALB server group.

N is the number of the ALB server group. The number of ALB server groups that can be associated with a scaling group is limited. To view or request an increase in the quota, go to Quota Center.

AlbServerGroup.N.Weight

Integer

No

100

After Auto Scaling adds an instance to an ALB server group, this is the weight of the instance as a backend server. A higher weight means the instance is allocated more access requests. If the weight is 0, the instance does not receive access requests. Valid values: 0 to 100.

N is the number of the ALB server group.

AlbServerGroup.N.Port

Integer

No

22

After Auto Scaling adds an instance to an ALB server group, this is the port number used by the instance. Valid values: 1 to 65535.

N is the number of the ALB server group.

Note

If the value of N is the same but the value of Port is different, the system associates the ALB server group with the scaling group on multiple different ports by default.

ServerGroup.N.ServerGroupId

String

No

sgp-5yc3bd9lfyh*****

The ID of the server group.

ServerGroup.N.Type

String

No

ALB

The type of the server group. Valid values:

  • ALB: Application Load Balancer.

  • NLB: Network Load Balancer.

ServerGroup.N.Weight

Integer

No

100

After Auto Scaling adds an instance to a server group, this is the weight of the instance as a backend server. Valid values: 0 to 100.

A higher weight means the instance is allocated more access requests. If the weight is 0, the instance does not receive access requests.

ServerGroup.N.Port

Integer

No

22

After Auto Scaling adds an instance to a server group, this is the port number used by the instance. Valid values: 1 to 65535.

AzBalance

Boolean

No

false

Specifies whether to evenly distribute the capacity of the scaling group across multiple zones. This parameter takes effect only when MultiAZPolicy is set to COMPOSABLE. Valid values:

  • true: The capacity of the scaling group is evenly distributed across multiple zones.

  • false: The capacity of the scaling group is not evenly distributed across multiple zones.

Default value: false.

AllocationStrategy

String

No

priority

The capacity allocation policy. This policy determines how the scaling group selects available instance types to meet the capacity requirements. The policy applies to both pay-as-you-go and spot instances. This parameter takes effect only when MultiAZPolicy is set to COMPOSABLE. Valid values:

  • priority: Instances are created in the order of the configured instance types.

  • lowestPrice: Instances are created based on the vCPU unit price from lowest to highest.

Default value: priority.

SpotAllocationStrategy

String

No

lowestPrice

The allocation policy for spot instances. You can use this parameter to separately specify the allocation policy for spot instances. This parameter takes effect only when MultiAZPolicy is set to COMPOSABLE. Valid values:

  • priority: Instances are created in the order of the configured instance types.

  • lowestPrice: Instances are created based on the vCPU unit price from lowest to highest.

Default value: priority.

MaxInstanceLifetime

Integer

No

null

The maximum lifetime of an instance in the scaling group. Unit: seconds.

Valid values: [86400, Integer.maxValue].

Default value: null.

Note

This parameter is not supported for scaling groups of the ECI type or scaling groups for which the economical mode is enabled.

CustomPolicyARN

String

No

acs:fc:cn-zhangjiakou:16145688****:services/ess_custom_terminate_policy.LATEST/functions/ess_custom_terminate_policy_name

The ARN of the custom scale-in policy (Function). This parameter takes effect only when the first removal policy in RemovalPolicies is set to CustomPolicy.

ResourceGroupId

String

No

rg-123****

The ID of the resource group to which the new scaling group belongs.

Note

The new scaling group is placed in the specified resource group. If you do not specify this parameter, the scaling group is placed in the default resource group.

LoadBalancerConfig.N.LoadBalancerId

String

No

147b46d767c-cn-qingdao-cm5****

The ID of the CLB (formerly SLB) instance.

LoadBalancerConfig.N.Weight

Integer

No

10

After Auto Scaling adds an instance to a CLB (formerly SLB) server group, this is the weight of the instance as a backend server. A higher weight means the instance is allocated more access requests. If the weight is 0, the instance does not receive access requests.

Valid values: 0 to 100.

HealthCheckTypes.N

String

No

ECS

The list of health check methods for the scaling group. Valid values:

  • NONE: No health checks are performed.

  • ECS: Health checks are performed on instances in the scaling group. This value enables instance health checks for both ECS and ECI scaling groups.

  • LOAD_BALANCER: The health status of an instance is determined by the health check results of the associated load balancer. This option does not support CLB.

Default value: ECS.

DBInstance.N.DBInstanceId

String

No

rm-m5eqju85s45mu0***

The ID of the database instance.

DBInstance.N.Type

String

No

RDS

The type of the database. Valid values:

  • RDS

  • Redis

  • MongoDB

Default value: RDS.

DBInstance.N.AttachMode

String

No

SecurityIp

The method for associating the database with the scaling group. Valid values:

  • SecurityIp: The IP whitelist mode. The private IP addresses of scaled-out instances are automatically added to the IP whitelist of the database. This mode is supported only for RDS databases.

  • SecurityGroup: The security group mode. The security group of the scaling configuration is added to the security group whitelist of the database. This allows instances in the security group to access the database.

StopInstanceTimeout

Integer

No

60

The timeout period for waiting for an ECS instance to stop during a scale-in. Unit: seconds.

Valid values: 30 to 240.

Note
  • This parameter takes effect only during scale-in processes when ScalingPolicy is set to `release`.

  • If you set this parameter, the system waits for the instance to stop for the duration of StopInstanceTimeout. After the timeout, the scale-in continues regardless of whether the instance has stopped.

  • If you do not set this parameter, the system waits for a long time for the instance to stop. The scale-in continues only after the instance has stopped. If the instance fails to stop, the scale-in process rolls back and fails.

CapacityOptions.OnDemandBaseCapacity

Integer

No

30

The minimum number of pay-as-you-go instances that are required for the scaling group. If the number of pay-as-you-go instances in the scaling group is less than this value, the system preferentially creates pay-as-you-go instances. Valid values: 0 to 1000.

When the MultiAZPolicy parameter is set to COMPOSABLE, the default value is 0.

CapacityOptions.OnDemandPercentageAboveBaseCapacity

Integer

No

20

The percentage of pay-as-you-go instances among the excess instances after the minimum pay-as-you-go instance requirement (OnDemandBaseCapacity) is met. Valid values: 0 to 100.

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

CapacityOptions.CompensateWithOnDemand

Boolean

No

true

This parameter takes effect only when MultiAZPolicy is set to COST_OPTIMIZED. It specifies whether to allow automatic creation of pay-as-you-go instances to meet the required number of ECS instances if spot instances cannot be created due to reasons such as price or insufficient inventory. Valid values:

  • true: Yes.

  • false: No.

Default value: true.

CapacityOptions.SpotAutoReplaceOnDemand

Boolean

No

false

If you enable CompensateWithOnDemand, the system may create pay-as-you-go instances if spot instances are unavailable. This can cause the proportion of pay-as-you-go instances to exceed the value of OnDemandPercentageAboveBaseCapacity. To prevent these pay-as-you-go instances from running for a long time, the system attempts to replace the excess pay-as-you-go instances with spot instances. Valid values:

  • true: Yes.

  • false: No.

Default value: false.

CapacityOptions.PriceComparisonMode

String

No

PricePerUnit

The price comparison mode for the cost optimization policy of the scaling group. Valid values:

  • PricePerUnit: Compares prices based on the price per unit of capacity.

    The capacity of an instance in a scaling group is equal to the weight set for the instance type. The default is 1, which means one ECS instance has a capacity of 1.

  • PricePerVCpu: Compares prices based on the price per vCPU.

Default value: PricePerUnit.

BalanceMode

String

No

BalancedBestEffort

The zone balancing mode. This parameter takes effect only when zone balancing is enabled. Valid values:

  • BalancedBestEffort:

    If resources fail to be created in a zone, the system falls back to other zones to ensure that resources are delivered on a best-effort basis.

  • BalancedOnly:

    If resources fail to be created in a zone, the system does not fall back to other zones. The scale-out activity is partially successful. This prevents excessive imbalance of resources across different zones.

Default value: BalancedBestEffort.

AutoRebalance

Boolean

No

false

Specifies whether to enable automatic rebalancing for the scaling group. This parameter takes effect only when BalancedOnly is enabled for a zone-balanced scaling group. Valid values:

  • false: Does not enable automatic rebalancing for the scaling group.

  • true: Enables automatic rebalancing for the scaling group. The scaling group automatically detects the capacity in each zone. If the capacity is imbalanced across zones, the scaling group automatically performs a scale-out or scale-in activity to rebalance the capacity.

Default value: false.

Response parameters

Parameter

Type

Example

Description

RequestId

String

473469C7-AA6F-4DC5-B3DB-A3DC0DE3****

The ID of the request.

ScalingGroupId

String

asg-bp14wlu85wrpchm0****

The ID of the scaling group.

Examples

Sample request

http(s)://ess.aliyuncs.com/?Action=CreateScalingGroup
&ScalingGroupName=scalinggroup****
&LaunchTemplateId=lt-m5e3ofjr1zn1aw7****
&LaunchTemplateVersion=Default
&InstanceId=i-28wt4****
&RegionId=cn-qingdao
&MinSize=2
&MaxSize=20
&DefaultCooldown=300
&LoadBalancerIds=["lb-bp1u7etiogg38yvwz****", "lb-bp168cqrux9ai9l7f****", "lb-bp1jv3m9zvj22ufxp****"]
&DBInstanceIds=["rm-bp142f86de0t7****", "rm-bp18l1z42ar4o****", "rm-bp1lqr97h4aqk****"]
&RemovalPolicy.1=OldestScalingConfiguration
&RemovalPolicy.2=OldestInstance
&RemovalPolicy.3=NewestInstance
&VSwitchId=vsw-bp14zolna43z266bq****
&MultiAZPolicy=PRIORITY
&HealthCheckType=ECS
&ScalingPolicy=recycle
&ClientToken=123e4567-e89b-12d3-a456-42665544****
&OnDemandBaseCapacity=30
&OnDemandPercentageAboveBaseCapacity=20
&SpotInstanceRemedy=true
&CompensateWithOnDemand=true
&SpotInstancePools=5
&DesiredCapacity=5
&GroupDeletionProtection=true
&GroupType=ECS
&ContainerGroupId=eci-uf6fonnghi50u374****
&VSwitchIds=["vsw-bp14zolna43z266bq****"]
&LifecycleHook=[{"DefaultResult":"CONTINUE","LifecycleHookName":"lifecyclehook****","LifecycleTransition":"SCALE_OUT","NotificationMetadata":"Test","NotificationArn":"acs:ess:cn-hangzhou:1111111111:queue/queue2","HeartbeatTimeout":600}]
&VServerGroup=[{"VServerGroupAttribute":[{"VServerGroupId":"rsp-bp1443g77****","Weight":100,"Port":22}],"LoadBalancerId":"lb-bp1u7etiogg38yvwz****"}]
&Tag=[{"Key":"Department","Value":"Finance","Propagate":false}]
&LaunchTemplateOverride=[{"InstanceType":"ecs.c5.xlarge","WeightedCapacity":4,"SpotPriceLimit":0.025}]
&AlbServerGroup=[{"AlbServerGroupId":"sgp-ddwb0y0g6y9bjm****","Weight":100,"Port":22}]
&ServerGroup=[{"ServerGroupId":"sgp-5yc3bd9lfyh*****","Type":"ALB","Weight":100,"Port":22}]
&AzBalance=false
&AllocationStrategy=priority
&SpotAllocationStrategy=lowestPrice
&CustomPolicyARN=acs:fc:cn-zhangjiakou:16145688****:services/ess_custom_terminate_policy.LATEST/functions/ess_custom_terminate_policy_name
&ResourceGroupId=rg-123****
&LoadBalancerConfig=[{"LoadBalancerId":"147b46d767c-cn-qingdao-cm5****","Weight":10}]
&HealthCheckTypes=["ECS"]
&DBInstance=[{"DBInstanceId":"rm-m5eqju85s45mu0***","Type":"RDS","AttachMode":"SecurityIp"}]
&StopInstanceTimeout=60
&CapacityOptions={"OnDemandBaseCapacity":30,"OnDemandPercentageAboveBaseCapacity":20,"CompensateWithOnDemand":true,"SpotAutoReplaceOnDemand":false}
&<Common request parameters>

Sample responses

XML format

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

<CreateScalingGroupResponse>
    <RequestId>473469C7-AA6F-4DC5-B3DB-A3DC0DE3****</RequestId>
    <ScalingGroupId>asg-bp14wlu85wrpchm0****</ScalingGroupId>
</CreateScalingGroupResponse>

JSON format

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

{
  "RequestId" : "473469C7-AA6F-4DC5-B3DB-A3DC0DE3****",
  "ScalingGroupId" : "asg-bp14wlu85wrpchm0****"
}

Error codes

For a list of error codes, visit the 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 specified RDS instance must be in the Running state.

400

IncorrectLoadBalancerHealthCheck

The current health check type of specified load balancer does not support this action.

Health checks must be enabled for the specified CLB instance.

400

IncorrectLoadBalancerStatus

The current status of the specified load balancer does not support this action.

The specified CLB instance must be in the active state.

400

IncorrectVSwitchStatus

The current status of virtual switch does not support this operation.

The vSwitch is unavailable. ECS instances cannot be created.

400

InvalidDBInstanceId. RegionMismatch

DB instance "XXX" and the specified scaling group are not in the same Region.

The specified RDS instance and the scaling group must be in the same region.

400

InvalidLoadBalancerId.IncorrectAddressType

The current address type of specified load balancer does not support this action.

If you specify a vSwitch, the CLB instance must be of the internal network type.

400

InvalidLoadBalancerId.IncorrectInstanceNetworkType

The network type of the instance in specified Load Balancer does not support this action.

The network type of the ECS instances in the specified CLB instance must be the same as 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 specified CLB instance and the scaling group must be 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 ECS instances attached to the CLB instance and the vSwitch must be in the same VPC.

400

InvalidParameter

The specified value of parameter "ScalingPolicy" is not valid.

The specified reclaim mode parameter is invalid.

400

InvalidParameter.Conflict

The value of parameter &lt;parameter name&gt; and parameter &lt;parameter name&gt; are conflict.

The specified MinSize cannot be greater than MaxSize.

400

InvalidScalingGroupName.Duplicate

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

The scaling group name already exists.

400

QuotaExceeded.DBInstanceSecurityIP

Security IP quota exceeded in DB instance "XXX".

The number of IP addresses in the whitelist of the specified RDS instance has reached the upper limit.

400

QuotaExceeded.PrivateIpAddress

Private IP address quota exceeded in the specified virtual switch.

The vSwitch cannot allocate more private IP addresses.

400

QuotaExceeded.ScalingGroup

Scaling group quota exceeded.

The number of scaling groups that you can use has reached the upper limit.

400

QuotaExceeded.VPCInstance

Instance quota exceeded in the specified VPC.

The number of instances in the VPC has exceeded the upper limit.

404

InvalidDBInstanceId.NotFound

DB instance "XXX" does not exist.

The specified RDS instance does not exist.

404

InvalidLoadBalancerId.NotFound

The specified Load Balancer does not exist.

The specified CLB instance does not exist.

404

InvalidRegionId.NotFound

The specified region does not exist.

The specified region does not exist.

404

InvalidVSwitchId.NotFound

The specified virtual switch does not exist.

The specified vSwitch does not exist.

400

LaunchTemplateVersionSet.NotFound

The specific version of launch template is not exist.

The specified version of the launch template does not exist.

400

LaunchTemplateSet.NotFound

The specified launch template set is not found.

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 specified version of the launch template is missing image information.

400

TemplateMissingParameter.InstanceTypes

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

The specified version of the launch template is missing instance type information.

400

TemplateMissingParameter.SecurityGroup

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

The specified version of the launch template is missing security group information.

400

TemplateVersion.NotNumber

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

The specified fixed version number of the launch template is not a number.

400

AlbServerGroup.NotExist

The ServerGroup "%s" do(es) not exist.

The specified ALB server group does not exist in your account.