Creates a scaling rule. The purpose of a scaling rule varies based on its type. You can use a scaling rule to trigger a scaling activity or adjust the boundary values for a scaling group. You can call the CreateScalingRule operation to create different types of scaling rules based on your business requirements. For example, if your business requires only automatic adjustment of boundary values for a scaling group, you can call the CreateScalingRule operation to create a predictive scaling rule.
Usage notes
Before you call the CreateScalingRule operation, take note of the following items:
If you set AdjustmentType to TotalCapacity, the total number of Elastic Compute Service (ECS) instances or elastic container instances in the scaling group is adjusted to a specific number when the scaling rule that you created by calling the CreateScalingRule operation is applied. You must set AdjustmentValue to an integer that is greater than 0.
If you set AdjustmentType to QuantityChangeInCapacity or PercentChangeInCapacity, a positive value of AdjustmentValue specifies that a specific number of ECS instances or elastic container instances are added to the scaling group. A negative value of AdjustmentValue specifies that a specific number of ECS instances or elastic container instances are removed from the scaling group.
If you set AdjustmentType to PercentChangeInCapacity, Auto Scaling calculates the number of ECS instances or elastic container instances to add or remove by using the following formula: Current capacity of the scaling group (Total Capacity) × Value of AdjustmentValue/100. The result is rounded off to determine the final adjustment count.
If you specify a cooldown period (Cooldown) for a scaling rule, the cooldown period of the scaling rule takes effect after you apply the scaling rule. If you do not specify a cooldown period (Cooldown) for a scaling rule, the default cooldown period (DefaultCooldown) of the scaling group takes effect after you apply the scaling rule.
You can create only a limited number of scaling rules for a scaling group. For more information, see Limits.
The following API operations may use the unique identifier of a scaling rule (ScalingRuleAri) that is returned by the CreateScalingRule operation:
ExecuteScalingRule: You can call this operation to manually execute a scaling rule. When you call the ExecuteScalingRule operation, you can set ScalingRuleAri to the unique identifier of the scaling rule that you want to apply.
CreateScheduledTask: You can call this operation to create a scheduled task for a scaling rule. When you call the CreateScheduledTask operation, you can set ScalingRuleAri to the unique identifier of the scaling rule for which you want to create a scheduled task.
Debugging
Request parameters
Parameter | Type | Required | Example | Description |
Action | String | Yes | CreateScalingRule | The operation that you want to perform. Set the value to CreateScalingRule. |
ScalingGroupId | String | Yes | asg-bp1ffogfdauy0jw0**** | The ID of the scaling group for which you want to create the scaling rule. |
ScalingRuleName | String | No | scalingrule**** | The name of the scaling rule. 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 name of each scaling rule must be unique within the same Alibaba Cloud account in a region. Note If you leave this parameter empty, the scaling rule ID is used. |
Cooldown | Integer | No | 60 | The cooldown period of the scaling rule. This parameter is available only if you set ScalingRuleType to SimpleScalingRule. Valid values: 0 to 86400. Unit: seconds. You can leave this parameter empty. |
MinAdjustmentMagnitude | Integer | No | 1 | The lower limit for the number of instances in each adjustment. This parameter takes effect only if you set |
AdjustmentType | String | No | QuantityChangeInCapacity | The adjustment method used by the scaling rule. If you set ScalingRuleType to SimpleScalingRule or StepScalingRule, you must specify this parameter. Valid values:
|
AdjustmentValue | Integer | No | 100 | The number of instances that can be added to or removed from the scaling group based on the scaling rule. If you set ScalingRuleType to SimpleScalingRule or StepScalingRule, you must specify this parameter. The maximum number of ECS instances that can be added or removed in a single scaling operation is 1,000 regardless of the scenario. The value range of this parameter varies based on the value of AdjustmentType.
|
ScalingRuleType | String | No | SimpleScalingRule | The type of the scaling rule. Valid values:
Default value: SimpleScalingRule. |
EstimatedInstanceWarmup | Integer | No | 300 | The warmup period of instances that can be added to or removed from the scaling group. You can specify this parameter only for simple scaling rules and step scaling rules. Auto Scaling adds ECS instances that are in the Warmup state to a scaling group, but does not report the monitoring data of the ECS instances to CloudMonitor during the warmup period. Note When Auto Scaling calculates the number of ECS instances that can be scaled, ECS instances in the Warmup state are not included in the current capacity of the scaling group. Valid values: 0 to 86400. Unit: seconds. Default value: 300. |
MetricName | String | No | CpuUtilization | The predefined metric that you want to monitor. If you set ScalingRuleType to TargetTrackingScalingRule or PredictiveScalingRule, you must specify this parameter. Valid values if you set ScalingRuleType to TargetTrackingScalingRule:
Valid values if you set ScalingRuleType to PredictiveScalingRule:
For more information, see Event-triggered tasks of the system monitoring type. |
TargetValue | Float | No | 0.125 | The expected value. If you set ScalingRuleType to TargetTrackingScalingRule or PredictiveScalingRule, you must specify this parameter. The value must be greater than 0 and can have up to three decimal places. |
DisableScaleIn | Boolean | No | false | Specifies whether to disable scale-in. This parameter is available only if you set ScalingRuleType to TargetTrackingScalingRule. Default value: false. |
ScaleInEvaluationCount | Integer | No | 15 | The number of consecutive times that the event-triggered task created for scale-in events must meet the threshold conditions before an alert is triggered. After you create a target tracking scaling rule, an event-triggered task is automatically created and associated with the scaling rule. Default value: 15. |
ScaleOutEvaluationCount | Integer | No | 3 | The number of consecutive times that the event-triggered task created for scale-out events must meet the threshold conditions before an alert is triggered. After you create a target tracking scaling rule, an event-triggered task is automatically created and associated with the scaling rule. Default value: 3. |
PredictiveScalingMode | String | No | PredictAndScale | The mode of the predictive scaling rule. Valid values:
Default value: PredictAndScale. |
PredictiveValueBehavior | String | No | MaxOverridePredictiveValue | The action performed based on the predicted maximum value Valid values:
Default value: MaxOverridePredictiveValue. |
PredictiveValueBuffer | Integer | No | 50 | The ratio based on which the predicted value is increased if you set Default value: 0. |
PredictiveTaskBufferTime | Integer | No | 30 | The amount of buffer time before prediction tasks are run. By default, all prediction tasks that are automatically created based on a predictive scaling rule are run on the hour. You can specify a buffer time for resource preparation before prediction tasks are run. Valid values: 0 to 60. Unit: minutes. Default value: 0. |
InitialMaxSize | Integer | No | 100 | The maximum number of ECS instances that can be added to the scaling group. If you specify InitialMaxSize, you must also specify PredictiveValueBehavior. The default value of this parameter is the value of MaxSize. |
StepAdjustment.N.MetricIntervalUpperBound | Float | No | 5.0 | The upper limit of a step adjustment. This parameter takes effect only if you set ScalingRuleType to StepScalingRule. Valid values: -9.999999E18 to 9.999999E18. |
StepAdjustment.N.ScalingAdjustment | Integer | No | 1 | The number of ECS instances that you want to scale in each step adjustment. This parameter is available only if you set ScalingRuleType to StepScalingRule. |
StepAdjustment.N.MetricIntervalLowerBound | Float | No | 1.0 | The lower limit of a step adjustment. This parameter takes effect only if you set ScalingRuleType to StepScalingRule. Valid values: -9.999999E18 to 9.999999E18. |
RegionId | String | No | cn-hangzhou | The region ID of the scaling group. |
AlarmDimension.N.DimensionKey | String | No | rulePool | The dimension key of the metric. |
AlarmDimension.N.DimensionValue | String | No | sgp-l1cbirz451yxu2**** | The dimension value of the metric. |
Response parameters
Parameter | Type | Example | Description |
ScalingRuleAri | String | ari:acs:ess:cn-hangzhou:140692647406****:scalingrule/asr-bp1dvirgwkoowxk7**** | The unique identifier of the scaling rule. |
RequestId | String | 473469C7-AA6F-4DC5-B3DB-A3DC0DE3**** | The request ID. |
ScalingRuleId | String | asr-bp1dvirgwkoowxk7**** | The ID of the scaling rule. The ID is generated by the system and is globally unique. |
Examples
Sample requests
http(s)://ess.aliyuncs.com/?Action=CreateScalingRule
&ScalingGroupId=asg-bp1ffogfdauy0jw0****
&ScalingRuleName=scalingrule****
&Cooldown=60
&MinAdjustmentMagnitude=1
&AdjustmentType=QuantityChangeInCapacity
&AdjustmentValue=100
&ScalingRuleType=SimpleScalingRule
&EstimatedInstanceWarmup=300
&MetricName=CpuUtilization
&TargetValue=0.125
&DisableScaleIn=false
&ScaleInEvaluationCount=15
&ScaleOutEvaluationCount=3
&PredictiveScalingMode=PredictAndScale
&PredictiveValueBehavior=MaxOverridePredictiveValue
&PredictiveValueBuffer=50
&PredictiveTaskBufferTime=30
&InitialMaxSize=100
&StepAdjustment=[{"MetricIntervalUpperBound":5.0,"ScalingAdjustment":1,"MetricIntervalLowerBound":1.0}]
&RegionId=cn-hangzhou
&AlarmDimension=[{"DimensionKey":"rulePool","DimensionValue":"sgp-l1cbirz451yxu2****"}]
&<Common request parameters>
Sample success responses
XML
format
HTTP/1.1 200 OK
Content-Type:application/xml
<CreateScalingRuleResponse>
<ScalingRuleAri>ari:acs:ess:cn-hangzhou:140692647406****:scalingrule/asr-bp1dvirgwkoowxk7****</ScalingRuleAri>
<RequestId>473469C7-AA6F-4DC5-B3DB-A3DC0DE3****</RequestId>
<ScalingRuleId>asr-bp1dvirgwkoowxk7****</ScalingRuleId>
</CreateScalingRuleResponse>
JSON
format
HTTP/1.1 200 OK
Content-Type:application/json
{
"ScalingRuleAri" : "ari:acs:ess:cn-hangzhou:140692647406****:scalingrule/asr-bp1dvirgwkoowxk7****",
"RequestId" : "473469C7-AA6F-4DC5-B3DB-A3DC0DE3****",
"ScalingRuleId" : "asr-bp1dvirgwkoowxk7****"
}
Error codes
For a list of error codes, see Service error codes.
HTTP status code | Error code | Error message | Description |
404 | InvalidScalingGroupId.NotFound | The specified scaling group does not exist. | The specified scaling group does not exist within your Alibaba Cloud account. |
400 | InvalidScalingRuleName.Duplicate | The specified value of parameter <parameter name> is duplicated. | The name of the scaling rule already exists. |
400 | QuotaExceeded.ScalingRule | Scaling rule quota exceeded in the specified scaling group. | The maximum number of scaling rules in the current scaling group has been reached. |
400 | TargetTrackingScalingRule.UnsupportedMetric | Specific metric is not supported for target tracking scaling rule. | The target tracking scaling rule does not support the specified metric. |
400 | TargetTrackingScalingRule.DumplicateMetric | Only one TargetTrackingScaling rule for a given metric specification is allowed. | The metric is already specified for another target tracking scaling rule in the scaling group. |
400 | InvalidMinAdjustmentMagnitudeMismatchAdjustmentType | MinAdjustmentMagnitude is not supported by the specified adjustment type. | MinAdjustmentMagnitude does not support the adjustment method of the scaling rule. |
400 | InvalidStepAdjustments.MultipleNullUpperBound | At most one StepAdjustment may have an unspecified upper bound. | A step adjustment that does not have an upper limit already exists. |
400 | InvalidStepAdjustments.MultipleNullLowerBound | At most one StepAdjustment may have an unspecified lower bound. | A step adjustment that does not have a lower limit already exists. |
400 | InvalidStepAdjustments.NoNullLowerBound | There must be a StepAdjustment with an unspecified lower bound when one StepAdjustment has a negative lower bound. | A step adjustment has a negative lower limit, but no step adjustment without a lower limit exists. |
400 | InvalidStepAdjustments.NoNullUpperBound | There must be a StepAdjustment with an unspecified upper bound when one StepAdjustment has a positive upper bound. | A step adjustment has a positive upper limit, but no step adjustment without an upper limit exists. |
400 | InvalidStepAdjustments.Gap | StepAdjustment intervals can not have gaps between them. | The step adjustments have gaps. |
400 | InvalidStepAdjustments.Overlap | StepAdjustment intervals can not overlap. | The ranges of step adjustments overlap. |
400 | InvalidStepAdjustments.LowerGtUpper | LowerBound must be less than the UpperBound for StepAdjustment :%s. | The lower limit of a step adjustment is greater than or equal to the upper limit. |
400 | InvalidStepAdjustments.BothNull | Both lower and upper bounds of a StepAdjustment can not be left unspecified. | You cannot specify an upper limit and a lower limit for a step adjustment at the same time. |
400 | InvalidStepAdjustments.MaxNum | Your scaling rule can have at most %s StepAdjustments. | The maximum number of step adjustments in a scaling group has been reached. |
400 | StepBeyondPermitRange | Specific parameter "%s" beyond permit range. | The specified upper limit or lower limit for a step adjustment is invalid. |