All Products
Search
Document Center

:UpdateApplicationScalingRule

Last Updated:Nov 01, 2024

Updates the auto scaling policy of an application.

Operation description

If you want to configure more than 50 instances for an application, you must submit a ticket to add your account to the whitelist.

Debugging

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • The required resource types are displayed in bold characters.
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
sae:UpdateApplicationScalingRuleupdate
  • Application
    acs:sae:{#regionId}:{#accountId}:application/{#namespaceid}/{#appid}
    none
none

Request syntax

PUT /pop/v1/sam/scale/applicationScalingRule HTTP/1.1

Request parameters

ParameterTypeRequiredDescriptionExample
AppIdstringYes

The application ID.

7171a6ca-d1cd-4928-8642-7d5cfe69****
ScalingRuleNamestringYes

The name of the auto scaling policy. The name must start with a lowercase letter and can contain only lowercase letters, digits, and hyphens (-). The name cannot exceed 32 characters in length.

Note You cannot change the names of created policies.
timer-0800-2100
ScalingRuleTimerstringNo

The configurations of the scheduled auto scaling policy. This parameter is required when you set the ScalingRuleType parameter to timing or when you want to create a scheduled auto scaling policy by using an SDK.

Parameter description:

  • beginDate and endDate: specify the validity period of the scheduled auto scaling policy. beginDate specifies the start date and endDate specifies the end date. Take note of the following rules:

    • If you set the two parameters to null, the scheduled auto scaling policy is a long-term policy. Default values of the beginDate and endDate parameters: null.
    • If you set the two parameters to specific dates, the scheduled auto scaling policy can be triggered during the period between the two dates. For example, if you set beginDate to 2021-03-25 and endDate to 2021-04-25, the auto scaling policy is valid for one month.
  • period: specifies the frequency at which the scheduled auto scaling policy is executed. Valid values:

    • * * *: The scheduled auto scaling policy is executed at a specified point in time every day.

    • * * Fri,Mon: The scheduled auto scaling policy is executed at a specified point in time on one or more specified days of each week. GMT+8 is used. Valid values:

      • Sun
      • Mon
      • Tue
      • Wed
      • Thu
      • Fri
      • Sat
    • 1,2,3,28,31 * *: The scheduled auto scaling policy is executed at a specified point in time on one or more days of each month. Valid values: 1 to 31. If the month does not have a 31st day, the auto scaling policy is executed on the specified days other than the 31st day.

  • schedules: specifies the points in time at which the auto scaling policy is triggered and the number of application instances that are retained during the corresponding period of time. You can specify up to 20 points in time. Parameter description:

    • atTime: the point in time at which the policy is triggered. Format: Hour:Minute. Example: 08:00.

    • targetReplicas: specifies the number of application instances that you want to maintain by using this policy. You can also set the value to the minimum number of available instances required for each application release. Valid values: 1 to 50.

      **

      NoteMake sure that at least one instance is available during the application deployment and rollback to prevent your business from being interrupted. If you set the value to 0, business interruptions occur when the application is updated.

{"beginDate":null,"endDate":null,"period":"* * *","schedules":[{"atTime":"08:00","targetReplicas":10},{"atTime":"20:00","targetReplicas":3}]}
ScalingRuleMetricstringNo

The configurations of the metric-based auto scaling policy. This parameter is required if you set the ScalingRuleType parameter to metric.

Parameter description:

  • maxReplicas: the maximum number of instances in the application.

  • minReplicas: the minimum number of instances in the application.

  • metricType: the metric that is used to trigger the auto scaling policy.

    • CPU: the CPU utilization.
    • MEMORY: the memory usage.
    • tcpActiveConn: the average number of active TCP connections in an application instance within 30 seconds.
    • SLB_QPS: the average queries per second (QPS) of the Internet-facing Server Load Balancer (SLB) instance associated with an application instance within 15 seconds.
    • SLB_RT: the average response time of the Internet-facing SLB instance within 15 seconds.
  • metricTargetAverageUtilization: the limit on the metric specified by the metricType parameter.

    • The limit on the CPU utilization. Unit: percentage.
    • The limit on the memory usage. Unit: percentage.
    • The limit on the average number of active TCP connections per second.
    • The limit on the QPS of the Internet-facing SLB instance.
    • The limit on the response time of the Internet-facing SLB instance. Unit: milliseconds.
  • SlbProject: the Log Service project.

  • SlbLogstore: the Log Service Logstore.

  • Vport: the listener port for the SLB instance. HTTP and HTTPS are supported.

  • scaleUpRules: the scale-out rule.

  • scaleDownRules: the scale-in rule.

  • step: the scale-out or scale-in step size. The maximum number of instances that can be added or removed per unit time.

  • disabled: specifies whether to disable the application scale-in. If you set this parameter to true, the application instances are never scaled in. This prevents business risks during peak hours.

    • true: disables the application scale-in.
    • false: enables the application scale-in. Default value: false.
  • stabilizationWindowSeconds: the cooldown period during which the system is stable and does not perform scale-out or scale-in operations. Valid values: 0 to 3600. Unit: seconds. Default value: 0.

Note You can specify one or more metrics as the trigger conditions of the auto scaling policy. If you specify multiple metrics, the application is scaled out when the value of a metric is greater than or equal to the limit. The number of application instances after the scale-out cannot exceed the configured maximum number of application instances. If the values of all the metrics are less than the limits, the application is scaled in. The number of instances after the scale-in cannot be less than the configured minimum number of application instances.
{"maxReplicas":3,"minReplicas":1,"metrics":[{"metricType":"CPU","metricTargetAverageUtilization":20},{"metricType":"MEMORY","metricTargetAverageUtilization":30},{"metricType":"tcpActiveConn","metricTargetAverageUtilization":20},{"metricType":"SLB_QPS","MetricTargetAverageUtilization":25,"SlbProject":"aliyun-fc-cn-hangzhou-d95881d9-5d3c-5f26-a6b8-************","SlbLogstore":"function-log","Vport":"80"},{"metricType":"SLB_RT","MetricTargetAverageUtilization":35,"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}}
MinReadyInstancesintegerNo

The minimum number of available instances. Take note of the following rules:

  • If you set the value to 0, business interruptions occur when the auto-scaling policy is updated.
  • If you set the value to **-1**, the minimum number of available instances is automatically set to a system-recommended value. The value is the nearest integer to which the calculated result of the following formula is rounded up: Current number of instances × 25%. For example, if five instances are available, the minimum number of available instances is calculated by using the following formula: 5 × 25% = 1.25. In this case, the minimum number of available instances is 2.
Note Make sure that at least one instance is available during application deployment and rollback to prevent business interruptions.
3
MinReadyInstanceRatiointegerNo

The percentage of the minimum number of available instances. Take note of the following rules:

  • If you set the value to -1, the minimum number of available instances is not determined based on this parameter. This is the default value.
  • If you set the value to a number from 0 to 100, the minimum number of available instances is calculated by using the following formula: Current number of instances × (Value of MinReadyInstanceRatio × 100%). The value is the nearest integer rounded up from the calculated result. For example, if you set this parameter to 50, and five instances are available, the minimum number of available instances is 3.
Note When MinReadyInstance and MinReadyInstanceRatio are specified and MinReadyInstanceRatio is set to a number from 0 to 100, the value of **MinReadyInstanceRatio** takes precedence.**** For example, if MinReadyInstances is set to **5**, and MinReadyInstanceRatio is set to 50, the minimum number of available instances is set to the nearest integer rounded up from the calculated result of the following formula: Current number of instances × 50%.
-1

Response parameters

ParameterTypeDescriptionExample
object

The returned data.

RequestIdstring

The request ID.

91F93257-7A4A-4BD3-9A7E-2F6EAE6D****
TraceIdstring

The trace ID that is used to query the details of the request.

0a98a02315955564772843261e****
Dataobject

The returned result.

Timerobject

The details of the scheduled auto scaling policy.

EndDatestring

The end date of the validity period of the scheduled auto scaling policy. Take note of the following rules:

  • If BeginDate and EndDate are set to null, the auto scaling policy is a long-term policy. Default values of the beginDate and endDate parameters: null.
  • If the two parameters are set to specific dates, the scheduled auto scaling policy can be triggered during the period between the two dates. For example, if BeginDate is set to 2021-03-25 and EndDate is set to 2021-04-25, the auto scaling policy is valid for one month.
2021-04-25
BeginDatestring

The start date of the validity period of the scheduled auto scaling policy. Parameter description:

  • If BeginDate and EndDate are set to null, the auto scaling policy is a long-term policy. Default values of the beginDate and endDate parameters: null.
  • If the two parameters are set to specific dates, the scheduled auto scaling policy can be triggered during the period between the two dates. For example, if BeginDate is set to 2021-03-25 and EndDate is set to 2021-04-25, the auto scaling policy is valid for one month.
2021-03-25
Schedulesarray<object>

The points in time at which the auto scaling policy is triggered within one day.

Scheduleobject

The information about the point in time.

AtTimestring

The point in time. Format: Hour:Minute.

08:00
TargetReplicasinteger

The expected number of instances.

3
Periodstring

The frequency at which the scheduled auto scaling policy is executed. Valid values:

  • * * *: The scheduled auto scaling policy is executed at a specified point in time every day.

  • * * Fri,Mon: The scheduled auto scaling policy is executed at a specified point in time on one or more days of each week. GMT+8 is used. Valid values:

    • Sun
    • Mon
    • Tue
    • Wed
    • Thu
    • Fri
    • Sat
  • 1,2,3,28,31 * *: The scheduled auto scaling policy is executed at a specified point in time on one or more days of each month. Valid values: 1 to 31. If the month does not have a 31st day, the auto scaling policy is executed on the specified days other than the 31st day.

* * *
UpdateTimelong

The time when the auto scaling policy was updated. Unit: milliseconds.

1616642248938
AppIdstring

The application ID.

7171a6ca-d1cd-4928-8642-7d5cfe69****
CreateTimelong

The time when the auto scaling policy was created. Unit: milliseconds.

1616642248938
LastDisableTimelong

The time when the auto scaling policy was last disabled.

1641882854484
ScaleRuleEnabledboolean

Specifies whether to enable the auto scaling policy. Valid values:

  • true: The auto scaling policy is enabled.
  • false: The auto scaling policy is disabled.
true
ScaleRuleTypestring

The type of the auto scaling policy. Valid values:

  • timing: a scheduled auto scaling policy
  • metric: a metric-based auto scaling policy
  • mix: a hybrid auto scaling policy
timing
Metricobject

The details of the metric-based auto scaling policy.

Metricsarray<object>

The metrics that are used to trigger the auto scaling policy.

Metricobject

The information about the metric.

MetricTargetAverageUtilizationinteger

The limit on the metric.

  • The limit on the CPU utilization. Unit: percentage.
  • The limit on the memory usage. Unit: percentage.
  • The limit on the average number of active TCP connections per second.
  • The limit on the QPS of the Internet-facing SLB instance.
  • The limit on the response time of the Internet-facing SLB instance. Unit: milliseconds.
20
MetricTypestring

The metric that is used to trigger the auto scaling policy. Valid values:

  • CPU: the CPU utilization.
  • MEMORY: the memory usage.
  • tcpActiveConn: the average number of active TCP connections of an application instance within 30 seconds.
  • SLB_QPS: the average QPS of the Internet-facing SLB instance associated with an application instance within 15 seconds.
  • SLB_RT: the average response time of the Internet-facing SLB instance within 15 seconds.
CPU
MaxReplicasinteger

The maximum number of instances.

3
MinReplicasinteger

The minimum number of instances.

1
ScaleRuleNamestring

The name of the auto scaling policy.

test
Messagestring

The returned message. Take note of the following rules:

  • If the call is successful, success is returned.
  • If the call fails, an error code is returned.
success
ErrorCodestring

The error code returned. Take note of the following rules:

  • If the call is successful, ErrorCode is not returned.
  • If the call fails, ErrorCode is returned. For more information, see the "Error codes" section in this topic.
Null
Codestring

The HTTP status code. Valid values:

  • 2xx: The call was successful.
  • 3xx: The call was redirected.
  • 4xx: The call failed.
  • 5xx: A server error occurred.
200
Successboolean

Specifies whether the instances are successfully restarted. Valid values:

  • true
  • false
true

Examples

Sample success responses

JSONformat

{
  "RequestId": "91F93257-7A4A-4BD3-9A7E-2F6EAE6D****",
  "TraceId": "0a98a02315955564772843261e****",
  "Data": {
    "Timer": {
      "EndDate": "2021-04-25",
      "BeginDate": "2021-03-25",
      "Schedules": [
        {
          "AtTime": "08:00",
          "TargetReplicas": 3
        }
      ],
      "Period": "* * *"
    },
    "UpdateTime": 1616642248938,
    "AppId": "7171a6ca-d1cd-4928-8642-7d5cfe69****",
    "CreateTime": 1616642248938,
    "LastDisableTime": 1641882854484,
    "ScaleRuleEnabled": true,
    "ScaleRuleType": "timing",
    "Metric": {
      "Metrics": [
        {
          "MetricTargetAverageUtilization": 20,
          "MetricType": "CPU"
        }
      ],
      "MaxReplicas": 3,
      "MinReplicas": 1
    },
    "ScaleRuleName": "test"
  },
  "Message": "success",
  "ErrorCode": "Null\n",
  "Code": "200",
  "Success": true
}

Error codes

HTTP status codeError codeError messageDescription
400InvalidScalingRuleDate.BeginAfterEndThe specified beginning time is later than the ending time.The specified begin date is later than the end date.
400InvalidScalingRuleDate.FormatThe specified date is invalid.The specified date is invalid. The correct format is yyyy-MM-dd .
400InvalidScalingRuleName.NotFoundThe specified ScalingRuleName does not exist.The specified ScalingRuleName does not exist.
400InvalidScalingRuleTime.ConflictThe specified scaling rule time is invalid. Another schedule has been set for the specified time range. Please set a different time.The specified scaling rule time is invalid. Another schedule has been set for the specified time range. Please set a different time.
400InvalidScalingRuleTime.FormatThe specified time is invalid.The specified time is invalid. The correct format is HH:mm .
400QuotaExceeded.ScalingRuleTimeThe maximum number of scaling policy trigger time is exceeded.Scaling rule time quota exceeded.
400NoComputeResourceQuota.ExceedYour compute resource is insufficient. Please contact us to raise the quota.-
400NoComputeResourceQuota.App.ExceedYou can create %s instances for each application. Please submit a ticket to raise the quota.You can create %s instances for each application. please join the DingTalk group 32874633 for technical support.
400NoComputeResourceQuota.User.ExceedYour account is limited to create %s instances. Please submit a ticket to raise the quota.Your account is limited to create %s instances. please join the DingTalk group 32874633 for technical support.
400System.UpgradingThe system is being upgraded. Please try again later.-
400MinReadyInstances.Not.Smaller.ReplicasThe minimum number of available instances must be less than the number of application instances.The minimum number of available instances must be less than the number of application instances.
400MinReadyInstanceRatio.InvalidThe ratio of minimum available instances must be between 0 and 100.-
400Application.ChangerOrderRunningAn application change process is in progress. Please try again later.An application change process is in progress. Please try again later.

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
2024-08-30The Error code has changed. The request parameters of the API has changed. The response structure of the API has changedView Change Details
2023-05-24The Error code has changed. The response structure of the API has changedView Change Details
2022-12-19The Error code has changed. The response structure of the API has changedView Change Details
2022-11-09The Error code has changedView Change Details