All Products
Search
Document Center

Auto Scaling:CreateScalingRule

Last Updated:Sep 17, 2026

Creates a scaling rule.

Operation description

Operation description

Note the following information about the parameters:

  • If AdjustmentType is set to TotalCapacity, the number of ECS or ECI instances in the current scaling group is adjusted to the specified value. The corresponding AdjustmentValue must be greater than or equal to 0.

  • If AdjustmentType is set to QuantityChangeInCapacity or PercentChangeInCapacity, a positive AdjustmentValue indicates ECS instances are added, and a negative value indicates ECS instances are removed.

  • If AdjustmentType is set to PercentChangeInCapacity, Auto Scaling calculates the number of ECS or ECI instances to add or remove by using the following formula: Current number of instances in the scaling group (Total Capacity) × AdjustmentValue/100. The result is rounded to the nearest integer.

  • If a cooldown time (Cooldown) is specified in a scaling rule, the cooldown time specified in the scaling rule takes effect after the scaling activity triggered by the scaling rule is complete. If no cooldown time is specified in the scaling rule, the cooldown time specified for the scaling group (DefaultCooldown) takes effect.

  • The number of scaling rules that can be created in a scaling group is limited. For more information, see Limits.

  • The unique identifier of the scaling rule (ScalingRuleAri) that is returned can be used in the following operations:
    • You can specify the ScalingRuleAri parameter when you call the ExecuteScalingRule operation to manually execute the scaling rule.

    • You can specify the ScheduledAction parameter when you call the CreateScheduledTask operation to execute the scaling rule on a schedule.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

ess:CreateScalingRule

create

*ScalingGroup

acs:ess:{#regionId}:{#accountId}:scalinggroup/{#ScalingGroupId}

None None

Request parameters

Parameter

Type

Required

Description

Example

ScalingGroupId

string

Yes

The ID of the scaling group to which the scaling rule belongs.

asg-bp1ffogfdauy0jw0****

ScalingRuleName

string

No

The name of the scaling rule. The name must be 2 to 64 characters in length and can contain digits, uppercase letters, lowercase letters, Chinese characters, underscores (_), hyphens (-), and periods (.). It must start with a digit, letter, or Chinese character.

The name of the scaling rule must be unique within the same region and scaling group under the same account.

Note

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

scalingrule****

Cooldown

integer

No

The cooldown time of the scaling rule. This parameter is applicable only to simple scaling rules. Valid values: 0 to 86400. Unit: seconds.

Default value: empty.

60

MinAdjustmentMagnitude

integer

No

The minimum number of instances to adjust in the scaling rule. This parameter takes effect only when the scaling rule type is SimpleScalingRule or StepScalingRule and AdjustmentType is set to PercentChangeInCapacity.

1

AdjustmentType

string

No

The adjustment method of the scaling rule. This parameter is applicable to simple scaling rules and step scaling rules, and is required in this case. Valid values:

  • QuantityChangeInCapacity: adds or removes a specified number of ECS instances.

  • PercentChangeInCapacity: adds or removes a specified percentage of ECS instances.

  • TotalCapacity: adjusts the number of ECS instances in the current scaling group to a specified value.

QuantityChangeInCapacity

AdjustmentValue

integer

No

The adjustment value of the scaling rule. This parameter is applicable to simple scaling rules and step scaling rules, and is required in this case. The number of ECS instances adjusted in a single scaling activity cannot exceed 1,000. Valid values vary based on the adjustment method:

  • QuantityChangeInCapacity: -1000 to 1000.

  • PercentChangeInCapacity: -100 to 10000.

  • TotalCapacity: 0 to 2000.

100

ScalingRuleType

string

No

The type of the scaling rule. Valid values:

  • SimpleScalingRule: simple scaling. Adjusts the number of ECS or ECI instances based on the adjustment method (AdjustmentType) and adjustment value (AdjustmentValue).

  • TargetTrackingScalingRule: target tracking scaling rule. Dynamically calculates the number of ECS or ECI instances to scale based on a predefined monitoring metric (MetricName) and attempts to keep the monitoring metrics value close to the target value (TargetValue).

  • StepScalingRule: step scaling rule. Provides step-based extension based on thresholds and metric values.

  • PredictiveScalingRule: predictive scaling rule. Uses machine learning to analyze historical monitoring data of the scaling group, predict future monitoring metrics values, and support automatic creation of scheduled tasks to set scaling group boundaries.

Default value: SimpleScalingRule.

SimpleScalingRule

EstimatedInstanceWarmup

integer

No

The warm-up period of an instance. This parameter is applicable to target tracking scaling rules and step scaling rules. An ECS instance in the warm-up state is added to the scaling group as expected, but does not report monitoring data to CloudMonitor during the warm-up period.

Note

When the number of ECS instances to scale is dynamically calculated, instances in the warm-up state are not counted toward the current number of instances.

Valid values: 0 to 86400. Unit: seconds.

Default value: 300.

300

MetricName

string

No

The predefined metric. This parameter is applicable to target tracking scaling rules and predictive scaling rules, and is required in this case.

Valid values for target tracking scaling rules:

  • CpuUtilizationAgent: (Agent) CPU utilization (recommended).

  • MemoryUtilization: (Agent) memory utilization (recommended).

  • CpuUtilization: (ECS) average CPU utilization.

  • IntranetTx: (ECS) average outbound traffic over the internal network.

  • IntranetRx: (ECS) average inbound traffic over the internal network.

  • VpcInternetTx: (ECS) average outbound traffic over the Internet.

  • VpcInternetRx: (ECS) average inbound traffic over the Internet.

  • LoadBalancerRealServerAverageQps: (ALB) average QPS per server in a server group.

Valid values for predictive scaling rules:

  • CpuUtilization: (ECS) average CPU utilization.

  • IntranetRx: (ECS) average inbound traffic over the internal network.

  • IntranetTx: (ECS) average outbound traffic over the internal network.

For more information, see Event-triggered tasks for system monitoring.

CpuUtilization

TargetValue

number

No

The target value. This parameter is applicable to target tracking scaling rules and predictive scaling rules, and is required in this case. The value of TargetValue can have up to three decimal places and must be greater than 0.

0.125

DisableScaleIn

boolean

No

Specifies whether to disable scale-in. This parameter is applicable only to target tracking scaling rules.

Default value: false.

false

ScaleInEvaluationCount

integer

No

After a target tracking scaling rule is created, an event-triggered task is automatically created. This parameter specifies the number of consecutive times that the conditional threshold must be met before the scale-in event-triggered task triggers an alert.

Default value: 15.

15

ScaleOutEvaluationCount

integer

No

After a target tracking scaling rule is created, an event-triggered task is automatically created. This parameter specifies the number of consecutive times that the conditional threshold must be met before the scale-out event-triggered task triggers an alert.

Default value: 3.

3

PredictiveScalingMode

string

No

The mode of the predictive scaling rule. Valid values:

  • PredictAndScale: generates prediction results and creates prediction tasks.

  • PredictOnly: generates prediction results but does not create prediction tasks.

Default value: PredictAndScale.

PredictAndScale

PredictiveValueBehavior

string

No

The method used to handle the maximum value for the predictive scaling rule. Valid values:

  • MaxOverridePredictiveValue: the initial maximum value overrides the predicted value. If the predicted value is greater than the initial maximum value, the maximum value of the prediction task is set to the initial maximum value.

  • PredictiveValueOverrideMax: the predicted value overrides the initial maximum value. If the predicted value is greater than the initial maximum value, the maximum value of the prediction task is set to the predicted value.

  • PredictiveValueOverrideMaxWithBuffer: the predicted value is increased by a specified percentage. The predicted value is increased based on the PredictiveValueBuffer ratio. If the increased value is greater than the initial maximum value, the increased value is used.

Default value: MaxOverridePredictiveValue.

MaxOverridePredictiveValue

PredictiveValueBuffer

integer

No

This parameter takes effect when PredictiveValueBehavior is set to PredictiveValueOverrideMaxWithBuffer. The predicted value is increased based on this ratio. If the increased value is greater than the initial maximum value, the increased value is used. Valid values: 0 to 100.

Default value: 0.

50

PredictiveTaskBufferTime

integer

No

The prediction tasks that are automatically created by the predictive scaling rule are executed on the hour by default. You can configure a buffer time to execute prediction tasks ahead of schedule to prepare resources in advance. Valid values: 0 to 60. Unit: minutes.

Default value: 0.

30

InitialMaxSize

integer

No

The maximum number of instances in the scaling group. This parameter is used together with PredictiveValueBehavior.

Default value: the value of MaxSize of the scaling group.

100

StepAdjustment

array<object>

No

The collection of step adjustment information for the step scaling rule.

object

No

The collection of step adjustment information for the step scaling rule.

MetricIntervalUpperBound

number

No

The upper boundary of the step adjustment. This parameter is applicable only to step scaling rules. Valid values: -9.999999E18 to 9.999999E18.

5.0

ScalingAdjustment

integer

No

The number of instances to scale for the step adjustment. This parameter is applicable only to step scaling rules.

1

MetricIntervalLowerBound

number

No

The lower boundary of the step adjustment. This parameter is applicable only to step scaling rules. Valid values: -9.999999E18 to 9.999999E18.

1.0

RegionId

string

No

The region ID of the scaling group.

cn-hangzhou

AlarmDimension

array<object>

No

The dimension information associated with the metric. This parameter is applicable to target tracking scaling rules. Set this parameter when the metric requires additional dimension information. For example, the LoadBalancerRealServerAverageQps metric requires the rulePool dimension information.

object

No

The dimension information associated with the metric. This parameter is applicable to target tracking scaling rules. Set this parameter when the metric requires additional dimension information. For example, the LoadBalancerRealServerAverageQps metric requires the rulePool dimension information.

DimensionKey

string

No

The key of the dimension associated with the metric.

rulePool

DimensionValue

string

No

The value of the dimension associated with the metric.

sgp-l1cbirz451yxu2****

MetricType

string

No

The type of the metric. Valid values:

  • system: uses CloudMonitor system metrics.

  • custom: uses custom metrics reported to CloudMonitor.

  • hybrid: uses Hybrid Cloud Monitoring metrics.

system

HybridMonitorNamespace

string

No

The ID of the Hybrid Cloud Monitoring monitoring metrics repository.

To manage metric repositories, see Manage metric repositories.

aliyun-test

HybridMetrics

array<object>

No

The Hybrid Cloud Monitoring monitoring metrics settings. For more information about how to configure this parameter, see Use formula-based custom target tracking scaling rules.

array<object>

No

Id

string

No

The reference ID of the metric in the metric expression.

a

Expression

string

No

The metric expression for multiple Hybrid Cloud Monitoring metrics. The calculation result of the expression is used to trigger scaling activities.

The expression must comply with the Reverse Polish Notation (RPN) specification, and only the + - * / operators are supported.

(a+b)/2

MetricName

string

No

The monitoring metrics name in the Hybrid Cloud Monitoring monitoring metrics repository.

AliyunSmq_NumberOfMessagesVisible

Statistic

string

No

The statistical method of the metric. Valid values:

  • Average: the average of all data points within the specified interval.

  • Minimum: the minimum value of all data points within the specified interval.

  • Maximum: the maximum value of all data points within the specified interval.

Average

Dimensions

array<object>

No

The metric dimensions. Specifies the resources to monitor for the metric.

object

No

DimensionKey

string

No

The key of the metric dimension.

queue

DimensionValue

string

No

The value of the metric dimension.

testQueue

AlarmOptions

object

No

The alert property definition.

Period

integer

No

The statistical period for monitoring data in the target tracking scaling rule. Unit: seconds. Valid values:

Note

Default value: 60.

60

Response elements

Element

Type

Description

Example

object

ScalingRuleAri

string

The unique identifier of the scaling rule.

ari:acs:ess:cn-hangzhou:140692647406****:scalingrule/asr-bp1dvirgwkoowxk7****

RequestId

string

The request ID.

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

ScalingRuleId

string

The ID of the scaling rule. The ID is generated by the system and is globally unique.

asr-bp1dvirgwkoowxk7****

Examples

Success response

JSON format

{
  "ScalingRuleAri": "ari:acs:ess:cn-hangzhou:140692647406****:scalingrule/asr-bp1dvirgwkoowxk7****",
  "RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3****",
  "ScalingRuleId": "asr-bp1dvirgwkoowxk7****"
}

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.