调用ScaleWithAdjustment基于指定调整规则触发弹性扩缩容。
接口说明
本接口区别于ExecuteScalingRule接口,您无需提前创建伸缩规则。
调用该接口需注意以下几点:
- 调用该接口前,请确保满足以下条件:
- 伸缩组处于Active状态。
- 伸缩组内没有执行中的伸缩活动。
- 当伸缩组没有执行中的伸缩活动时,该接口可以绕过冷却时间(Cooldown)直接执行伸缩活动。
- 如果伸缩规则需要增加的ECS实例数加上当前伸缩组的实例数(Total Capacity)大于最大实例数(MaxSize),则按Total Capacity=MaxSize执行伸缩活动。
- 如果当前伸缩组的实例数(Total Capacity)减去伸缩规则需要减少的ECS实例数小于最小实例数(MinSize),则按Total Capacity=MinSize执行伸缩活动。
调用该接口返回成功,只是表示弹性伸缩服务接受了该接口的调用请求,可以执行伸缩活动,但不代表伸缩活动能够执行成功。您需要通过返回的ScalingActivityId
查看该伸缩活动的执行状态。
调试
您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。
请求参数
名称 | 类型 | 是否必选 | 示例值 | 描述 |
---|---|---|---|---|
ScalingGroupId | String | 是 | asg-j6c1o397427hyjdc**** |
伸缩组的ID。 |
AdjustmentType | String | 是 | QuantityChangeInCapacity |
伸缩活动调整方式,取值范围:
|
AdjustmentValue | Integer | 是 | 100 |
伸缩活动调整值。任何情况下,单次调整的ECS实例台数都不能超过1000,否则会导致调整失败。不同调整方式对应的取值范围:
|
MinAdjustmentMagnitude | Integer | 否 | 1 |
伸缩活动最小调整实例数,仅当 |
ClientToken | String | 否 | 123e4567-e89b-12d3-a456-42665544**** |
用于保证请求的幂等性,防止重复提交请求。由客户端生成该参数值,要保证在不同请求间唯一,最大值不超过64个ASCII字符,且该参数值中不能包含非ASCII字符。 |
Action | String | 是 | ScaleWithAdjustment |
系统规定参数。取值:ScaleWithAdjustment。 |
SyncActivity | Boolean | 否 | false |
伸缩活动同步执行开关,仅对具有期望实例数配置项的伸缩组有效。取值范围:
说明 关于期望实例数的更多信息,请参见期望实例数。
默认值:false。 |
返回数据
名称 | 类型 | 示例值 | 描述 |
---|---|---|---|
ScalingActivityId | String | asa-bp175o6f6ego3r2j**** |
伸缩活动的ID。 |
RequestId | String | 473469C7-AA6F-4DC5-B3DB-A3DC0DE3**** |
请求ID。 |
ActivityType | String | CapacityChange |
伸缩活动的类型。 当 适用范围:期望实例数类型的伸缩组。 |
示例
请求示例
http(s)://ess.aliyuncs.com/?ScalingGroupId=asg-j6c1o397427hyjdc****
&AdjustmentType=QuantityChangeInCapacity
&AdjustmentValue=100
&MinAdjustmentMagnitude=1
&ClientToken=123e4567-e89b-12d3-a456-42665544****
&Action=ScaleWithAdjustment
&SyncActivity=false
&公共请求参数
正常返回示例
XML
格式
HTTP/1.1 200 OK
Content-Type:application/xml
<ScaleWithAdjustmentResponse>
<ScalingActivityId>asa-bp175o6f6ego3r2j****</ScalingActivityId>
<RequestId>473469C7-AA6F-4DC5-B3DB-A3DC0DE3****</RequestId>
<ActivityType>CapacityChange</ActivityType>
</ScaleWithAdjustmentResponse>
JSON
格式
HTTP/1.1 200 OK
Content-Type:application/json
{
"ScalingActivityId" : "asa-bp175o6f6ego3r2j****",
"RequestId" : "473469C7-AA6F-4DC5-B3DB-A3DC0DE3****",
"ActivityType" : "CapacityChange"
}
错误码
访问错误中心查看更多错误码。
HttpCode |
错误码 |
错误信息 |
描述 |
---|---|---|---|
403 |
Forbidden.Unauthorized |
A required authorization for the specified action is not supplied. |
您并未向弹性伸缩完整授权OpenAPI接口。 |
400 |
IncorrectScalingGroupStatus |
The current status of the specified scaling group does not support this action. |
指定伸缩规则所属的伸缩组未处于Active状态。 |
400 |
ScalingActivityInProgress |
You cannot delete a scaling group or launch a new scaling activity while there is a scaling activity in progress for the specified scaling group. |
指定伸缩规则所属的伸缩组有伸缩活动正在进行。 |
400 |
InsufficientBalance |
Your account does not have enough balance. |
账号余额不足。 |
400 |
QuotaExceed.Instance |
Living instance quota exceeded. |
ECS实例个数达到上限。 |
400 |
IncorrectLoadBalancerStatus |
The current status of the specified load balancer does not support this action. |
指定伸缩规则所属的伸缩组的负载均衡实例未处于active状态。 |
400 |
IncorrectLoadBalancerHealthCheck |
The current health check type of specified load balancer does not support this action. |
指定伸缩规则所属的伸缩组的负载均衡实例未开启健康检查。 |
400 |
InvalidLoadBalancerId.IncorrectInstanceNetworkType |
The network type of the instance in specified load balancer does not support this action. |
指定的负载均衡实例含有的ECS实例的网络类型与伸缩组的网络类型不匹配。 |
400 |
InvalidLoadBalancerId.VPCMismatch |
The specified virtual switch and the instance in specified load balancer are not in the same VPC. |
指定的伸缩组的负载均衡实例含有的ECS实例与VSwitchId不在同一个VPC当中。 |
400 |
IncorrectDBInstanceStatus |
The current status of DB instance "XXX" does not support this action. |
指定伸缩规则所属的伸缩组的RDS实例未处于running状态。 |
400 |
QuotaExceeded.DBInstanceSecurityIP |
Security IP quota exceeded in DB instance "XXX". |
指定伸缩规则所属的伸缩组的RDS实例访问白名单的IP个数达到上限。 |
400 |
QuotaExceeded.SecurityGroupInstance |
Instance quota exceeded in the specified security group. |
指定的安全组已添加的ECS实例个数达到上限。 |
400 |
IncorrectCapacity.NoChange |
To execute the specified scaling rule, the total capacity will not change. |
伸缩规则未造成伸缩组实例数的变化。 |
400 |
QuotaExceeded.ScalingInstance |
Scaling instance quota exceeded. |
弹性伸缩的ECS实例使用个数达到上限。 |
400 |
QuotaExceeded.AfterpayInstance |
Living afterpay instance quota exceeded. |
按量付费ECS实例的使用个数达到上限。 |
400 |
ResourceNotAvailable.ECS |
The specified region or zone does not offer the specified disk or instance category. |
指定的区域无法创建指定的ECS实例类型或磁盘类型。 |
400 |
ScalingRule.InvalidScalingRuleType |
Specific scaling rule type: %s can not be executed. |
无法执行当前类型的伸缩规则。 |
400 |
InvalidStepAdjustments.NoStepFound |
No adjustment step found for a metric value of: %s. |
未找到符合条件的分步执行步骤。 |
400 |
MissingParameter.MetricValue |
Metric value must be specified for StepScalingRule. |
执行分步伸缩规则必须指定指标值。 |
400 |
MissingParameter.BreachThreshold |
Breach threshold must be specified for StepScalingRule. |
执行分步伸缩规则必须指定阈值。 |
400 |
BreachThresholdBeyondPermitRange |
Specific parameter "%s" beyond permit range. |
阈值超过了可选范围。 |