更新应用弹性伸缩策略。
接口说明
使用须知
如果单个应用需要弹出超过 50 个实例,请联系 SAE 技术支持并申请白名单。更多信息,请参见联系我们。
调试
您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。
调试
授权信息
|
操作 |
访问级别 |
资源类型 |
条件关键字 |
关联操作 |
|
sae:UpdateApplicationScalingRule |
update |
*Application
|
无 | 无 |
请求语法
PUT /pop/v1/sam/scale/applicationScalingRule HTTP/1.1
请求参数
|
名称 |
类型 |
必填 |
描述 |
示例值 |
| AppId |
string |
是 |
应用 ID。 |
7171a6ca-d1cd-4928-8642-7d5cfe69**** |
| ScalingRuleName |
string |
是 |
已创建成功的弹性策略名。必须以小写字母开头,仅可包含小写字母、数字及短划线(-),不超过 32 个字符。 说明
弹性伸缩策略创建成功后,不可修改策略名。 |
timer-0800-2100 |
| ScalingRuleTimer |
string |
否 |
定时弹性策略的配置。当您选择定时弹性策略或使用 SDK 设置时,该参数必选。 参数说明如下:
|
{"beginDate":null,"endDate":null,"period":"* * *","schedules":[{"atTime":"08:00","targetReplicas":10},{"atTime":"20:00","targetReplicas":3}]} |
| ScalingRuleMetric |
string |
否 |
监控指标弹性策略的配置。当您选择监控指标弹性策略设置时,该参数必选。 参数说明如下:
说明
您可以选择设置一个或多个监控指标。当设置多个监控指标时,只要任何一个指标大于或者等于目标值,则应用进行扩容,扩容后实例数不高于应用最大实例数;如果所有指标均小于目标值,则应用进行缩容,缩容后实例数不低于应用最小实例数。 |
{"maxReplicas":3,"minReplicas":1,"metrics":[{"metricType":"CPU","metricTargetAverageUtilization":20},{"metricType":"MEMORY","metricTargetAverageUtilization":30},{"metricType":"tcpActiveConn","metricTargetAverageUtilization":20},{"metricType":"SLB_QPS","MetricTargetAverageUtilization":25,"slbId":"lb-xxx","slbProject":"aliyun-fc-cn-hangzhou-d95881d9-5d3c-5f26-a6b8-************","slbLogstore":"function-log","vport":"80"},{"metricType":"SLB_RT","MetricTargetAverageUtilization":35,"slbId":"lb-xxx","slbProject":"aliyun-fc-cn-hangzhou-d95881d9-5d3c-5f26-a6b8-************","slbLogstore":"function-log","vport":"80"}],"scaleUpRules":{"step":"100","disabled":false,"stabilizationWindowSeconds":0},"scaleDownRules":{"step":"100","disabled":false,"stabilizationWindowSeconds":300}} |
| MinReadyInstances |
integer |
否 |
最小存活实例数。取值说明如下:
说明
每次滚动部署最小存活的实例数建议≥1,保证业务不中断。 |
3 |
| MinReadyInstanceRatio |
integer |
否 |
最小存活实例数百分比。取值说明如下:
说明
当 MinReadyInstance 和 MinReadyInstanceRatio 同时传递时,且 MinReadyInstanceRatio 的取值非**-1**时,以 MinReadyInstanceRatio 参数为准。假设 MinReadyInstances 取值为 5,MinReadyInstanceRatio 取值为 50,则会用 50 来计算最小存活实例数。 |
-1 |
| EnableIdle |
boolean |
否 |
返回参数
|
名称 |
类型 |
描述 |
示例值 |
|
object |
返回信息。 |
||
| RequestId |
string |
请求 ID。 |
91F93257-7A4A-4BD3-9A7E-2F6EAE6D**** |
| TraceId |
string |
调用链 ID,用于精确查询调用信息。 |
0a98a02315955564772843261e**** |
| Data |
object |
返回结果。 |
|
| Timer |
object |
定时弹性伸缩。 |
|
| EndDate |
string |
定时弹性伸缩策略的短期结束日期。取值说明如下:
|
2021-04-25 |
| BeginDate |
string |
定时弹性伸缩策略的短期起始日期。取值说明如下:
|
2021-03-25 |
| Schedules |
array<object> |
单天内触发时间点。 |
|
|
object |
时间点数据。 |
||
| AtTime |
string |
时间点。格式:时:分。 |
08:00 |
| TargetReplicas |
integer |
目标实例数。 |
3 |
| MinReplicas |
integer |
最小实例数。 |
1 |
| MaxReplicas |
integer |
最大实例数。 |
10 |
| Period |
string |
执行定时弹性伸缩策略的周期。取值说明如下:
|
* * * |
| UpdateTime |
integer |
弹性伸缩策略的更新时间。单位:毫秒。 |
1616642248938 |
| AppId |
string |
应用 ID。 |
7171a6ca-d1cd-4928-8642-7d5cfe69**** |
| CreateTime |
integer |
弹性伸缩策略的创建时间。单位:毫秒。 |
1616642248938 |
| LastDisableTime |
integer |
最近一次禁用弹性伸缩策略的时间。 |
1641882854484 |
| ScaleRuleEnabled |
boolean |
是否启用弹性伸缩策略。取值说明如下:
|
true |
| ScaleRuleType |
string |
弹性伸缩策略类型。取值说明如下:
|
timing |
| Metric |
object |
监控指标弹性伸缩。 |
|
| Metrics |
array<object> |
监控指标弹性伸缩列表。 |
|
|
object |
监控指标数据。 |
||
| MetricTargetAverageUtilization |
integer |
监控指标的目标值。
|
20 |
| MetricType |
string |
监控指标触发条件。取值说明如下:
|
CPU |
| SlbProject |
string |
SLB 访问日志 Project。 |
test |
| SlbLogstore |
string |
SLB 访问日志 Logstore。 |
test |
| Vport |
string |
SLB 端口。 |
80 |
| SlbId |
string |
SLB 实例 ID。 |
lb-xxx |
| MaxReplicas |
integer |
最大实例数。 |
3 |
| MinReplicas |
integer |
最小实例数。 |
1 |
| ScaleRuleName |
string |
弹性伸缩策略名称。 |
test |
| EnableIdle |
boolean |
||
| Message |
string |
附加信息。取值说明如下:
|
success |
| ErrorCode |
string |
错误码。取值说明如下:
|
空 |
| Code |
string |
接口状态或 POP 错误码。取值说明如下:
|
200 |
| Success |
boolean |
重启应用实例是否成功。取值说明如下:
|
true |
示例
正常返回示例
JSON格式
{
"RequestId": "91F93257-7A4A-4BD3-9A7E-2F6EAE6D****",
"TraceId": "0a98a02315955564772843261e****",
"Data": {
"Timer": {
"EndDate": "2021-04-25",
"BeginDate": "2021-03-25",
"Schedules": [
{
"AtTime": "08:00",
"TargetReplicas": 3,
"MinReplicas": 1,
"MaxReplicas": 10
}
],
"Period": "* * *"
},
"UpdateTime": 1616642248938,
"AppId": "7171a6ca-d1cd-4928-8642-7d5cfe69****",
"CreateTime": 1616642248938,
"LastDisableTime": 1641882854484,
"ScaleRuleEnabled": true,
"ScaleRuleType": "timing",
"Metric": {
"Metrics": [
{
"MetricTargetAverageUtilization": 20,
"MetricType": "CPU",
"SlbProject": "test",
"SlbLogstore": "test",
"Vport": "80",
"SlbId": "lb-xxx"
}
],
"MaxReplicas": 3,
"MinReplicas": 1
},
"ScaleRuleName": "test",
"EnableIdle": true
},
"Message": "success",
"ErrorCode": "空",
"Code": "200",
"Success": true
}
错误码
|
HTTP status code |
错误码 |
错误信息 |
描述 |
|---|---|---|---|
| 400 | InvalidScalingRuleDate.BeginAfterEnd | The specified beginning time is later than the ending time. | 指定的开始时间晚于结束时间。 |
| 400 | InvalidScalingRuleDate.Format | The specified date is invalid. | 指定的日期不合法。正确的格式为yyyy-MM-dd。 |
| 400 | InvalidScalingRuleName.NotFound | The specified ScalingRuleName does not exist. | 指定的ScalingRuleName不存在。 |
| 400 | InvalidScalingRuleTime.Conflict | The specified scaling rule time is invalid. Another schedule has been set for the specified time range. Please set a different time. | 指定的弹性策略时间无效。该时间段已设置过定时策略,请重新选择时间设置。 |
| 400 | InvalidScalingRuleTime.Format | The specified time is invalid. | 指定的时间不合法。正确的格式为HH:mm。 |
| 400 | QuotaExceeded.ScalingRuleTime | The maximum number of scaling policy trigger time is exceeded. | 弹性策略触发时间到达上限。 |
| 400 | NoComputeResourceQuota.Exceed | Your compute resource is insufficient. Please contact us to raise the quota. | |
| 400 | NoComputeResourceQuota.App.Exceed | You can create %s instances for each application. Please submit a ticket to raise the quota. | 每个应用只允许创建%s个实例,请加入钉群32874633联系技术产品专家进行咨询。 |
| 400 | NoComputeResourceQuota.User.Exceed | Your account is limited to create %s instances. Please submit a ticket to raise the quota. | 您的账户限额%s个实例,请加入钉群32874633联系技术产品专家进行咨询。 |
| 400 | System.Upgrading | The system is being upgraded. Please try again later. | 系统正在升级,请稍后操作。 |
| 400 | MinReadyInstances.Not.Smaller.Replicas | The minimum number of available instances must be less than the number of application instances. | 最小可用实例数必须小于应用实例数。 |
| 400 | MinReadyInstanceRatio.Invalid | The ratio of minimum available instances must be between 0 and 100. | 最小存活实例数比例值必须在0~100之间。 |
| 400 | Application.ChangerOrderRunning | An application change process is in progress. Please try again later. | 应用有变更流程正在执行,请稍后重试。 |
访问错误中心查看更多错误码。
变更历史
更多信息,参考变更详情。