All Products
Search
Document Center

Auto Scaling:ScaleWithAdjustment

Last Updated:Jan 02, 2024

Scales instances in a scaling group based on the specified scaling policy. The ScaleWithAdjustment operation is different from the ExecuteScalingRule operation in that you can call the ScaleWithAdjustment operation to scale instances without creating any scaling rules in advance.

Usage notes

  • Before you call this operation, take note of the following items:

    • The specified scaling group is enabled.

    • No scaling activities in the scaling group are in progress.

  • If no scaling activities in the scaling group are in progress, the operation can trigger scaling activities before the cooldown period of the scaling group expires.

  • If the addition of a specific number of Elastic Compute Service (ECS) instances to the scaling group causes the total number of ECS instances in the scaling group to exceed the maximum number of instances that can be contained in the scaling group, Auto Scaling adds ECS instances until the total number of instances is equal to the maximum number of instances.

  • If the removal of a specific number of ECS instances from the scaling group causes the total number of ECS instances in the scaling group to be less than the minimum number of instances that must be contained in the scaling group, Auto Scaling removes ECS instances until the total number of instances is equal to the minimum number of instances.

A successful call indicates that Auto Scaling accepts the request. However, the scaling activity may still fail. You can obtain the status of a scaling activity by using the value of ScalingActivityId in the response.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code for different SDKs.

Request parameters

Parameter

Type

Required

Example

Description

ScalingGroupId

String

Yes

asg-j6c1o397427hyjdc****

The ID of the scaling group.

AdjustmentType

String

Yes

QuantityChangeInCapacity

Specifies how to scale instances. Valid values:

  • QuantityChangeInCapacity: adds the specified number of ECS instances to or removes the specified number of ECS instances from the scaling group.

  • PercentChangeInCapacity: adds the specified percentage of ECS instances to or removes the specified percentage of ECS instances from the scaling group.

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

AdjustmentValue

Integer

Yes

100

The number of ECS instances in each adjustment. The number of ECS instances in each adjustment cannot exceed 1,000. Valid values of AdjustmentValue vary based on the value of AdjustmentType.

  • Valid values if you set AdjustmentType to QuantityChangeInCapacity: -1000 to 1000.

  • Valid values if you set AdjustmentType to PercentChangeInCapacity: -100 to 10000.

  • Valid values if you set AdjustmentType to TotalCapacity: 0 to 2000.

MinAdjustmentMagnitude

Integer

No

1

The minimum number of instances that must be contained in each adjustment. This parameter takes effect only if you set AdjustmentType to PercentChangeInCapacity.

ClientToken

String

No

123e4567-e89b-12d3-a456-42665544****

The client token that is used to ensure the idempotence of the request. You can use the client to generate the token, but you must make sure that the token is unique among different requests. The token can contain only ASCII characters and cannot exceed 64 characters in length.

Action

String

Yes

ScaleWithAdjustment

The operation that you want to perform. Set the value to ScaleWithAdjustment.

SyncActivity

Boolean

No

false

Specifies whether to trigger the scaling activity in a synchronous manner. This parameter takes effect only on scaling groups for which you specified an expected number of instances. Valid values:

  • true: triggers the scaling activity in a synchronous manner. The scaling activity is triggered at the time when the scaling rule is executed.

  • false: does not trigger the scaling activity in a synchronous manner. After you change the expected number of instances for the scaling group, Auto Scaling checks whether the total number of instances in the scaling group matches the new expected number of instances and determines whether to trigger the scaling activity based on the check result.

Note

For more information about the Expected Number of Instances feature, see Expected number of instances.

Default value: false.

Overrides

Object

No

The overriding parameters that are used for scale-outs. You can specify this parameter if your scaling group is of the Elastic Container Instance type.

Cpu

Float

No

2

The number of vCPUs that you want to allocate to the instance.

Memory

Float

No

4

The memory size that you want to allocate to the instance. Unit: GiB.

ContainerOverride

Array

No

The container overriding parameters.

Name

String

No

container-1

The name of the container. If you want to use a container override parameter, you must specify a container name. The container override parameter takes effect only when the specified container name matches the container name in the scaling configuration.

Arg

Array of String

No

100

The container startup arguments. You can specify up to 10 arguments.

Command

Array of String

No

sleep

The container startup commands. You can specify up to 20 commands. Each command can contain up to 256 characters.

EnvironmentVar

Array

No

The information about environment variables.

Key

String

No

PATH

The key of the environment variable. The key must be 1 to 128 characters in length. Specify the key in the [0-9a-zA-Z] format. The key can contain underscores and cannot start with a digit.

Value

String

No

/usr/local/tomcat

The value of the environment variable. The value can be up to 256 characters in length.

Cpu

Float

No

2

The number of vCPUs that you want to allocate to the container.

Memory

Float

No

4

The memory size that you want to allocate to the container. Unit: GiB.

Response parameters

Parameter

Type

Example

Description

ScalingActivityId

String

asa-bp175o6f6ego3r2j****

The ID of the scaling activity.

RequestId

String

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

The request ID.

ActivityType

String

CapacityChange

The type of the scaling activity.

If ActivityType is set to CapacityChange, only the expected number of instances is changed during the scaling activity that is specified by ScalingActivityId and no scale-out is triggered.

This parameter is applicable to only scaling groups that have an expected number of instances.

Examples

Sample requests

http(s)://ess.aliyuncs.com/?ScalingGroupId=asg-j6c1o397427hyjdc****
&AdjustmentType=QuantityChangeInCapacity
&AdjustmentValue=100
&MinAdjustmentMagnitude=1
&ClientToken=123e4567-e89b-12d3-a456-42665544****
&Action=ScaleWithAdjustment
&SyncActivity=false
&Overrides={"Cpu":2.0,"Memory":4.0,"ContainerOverride":[{"Name":"container-1","Arg":["100"],"Command":["sleep"],"EnvironmentVar":[{"Key":"PATH","Value":"/usr/local/tomcat"}],"Cpu":2.0,"Memory":4.0}]}
&<Common request parameters>

Sample success responses

XML format

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 format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "ScalingActivityId" : "asa-bp175o6f6ego3r2j****",
  "RequestId" : "473469C7-AA6F-4DC5-B3DB-A3DC0DE3****",
  "ActivityType" : "CapacityChange"
}

Error codes

For a list of error codes, see Service error codes.

HTTP status code

Error code

Error message

Description

403

Forbidden.Unauthorized

A required authorization for the specified action is not supplied.

Auto Scaling is not authorized to call the operation.

400

IncorrectScalingGroupStatus

The current status of the specified scaling group does not support this action.

The scaling group to which the specified scaling rule belongs is not in the Active state.

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.

The scaling group of the specified scaling rule has a scaling activity in progress.

400

InsufficientBalance

Your account does not have enough balance.

The balance of your Alibaba Cloud account is insufficient.

400

QuotaExceed.Instance

Living instance quota exceeded.

The maximum number of ECS instances has been reached.

400

IncorrectLoadBalancerStatus

The current status of the specified load balancer does not support this action.

The Server Load Balancer (SLB) instance that is associated with the scaling group of the specified scaling rule is not in the Active state.

400

IncorrectLoadBalancerHealthCheck

The current health check type of specified load balancer does not support this action.

The Health Check feature is not enabled for the SLB instance that is associated with the scaling group of the specified scaling rule.

400

InvalidLoadBalancerId.IncorrectInstanceNetworkType

The network type of the instance in specified load balancer does not support this action.

The network type of an ECS instance that is attached to the associated SLB instance is different from the network type of the scaling group.

400

InvalidLoadBalancerId.VPCMismatch

The specified virtual switch and the instance in specified load balancer are not in the same VPC.

An ECS instance that is attached to the specified SLB instance does not reside in the same VPC as the vSwitch that is specified by VswitchID.

400

IncorrectDBInstanceStatus

The current status of DB instance "XXX" does not support this action.

The ApsaraDB RDS instance that is associated with the scaling group of the specified scaling rule is not in the Running state.

400

QuotaExceeded.DBInstanceSecurityIP

Security IP quota exceeded in DB instance "XXX".

The maximum number of IP addresses in the IP address whitelist of the ApsaraDB RDS instance that is associated with the scaling group of the specified scaling rule has been reached.

400

QuotaExceeded.SecurityGroupInstance

Instance quota exceeded in the specified security group.

The maximum number of ECS instances that are associated with the specified security group has been reached.

400

IncorrectCapacity.NoChange

To execute the specified scaling rule, the total capacity will not change.

The number of instances in the scaling group remains unchanged after the scaling rule is executed.

400

QuotaExceeded.ScalingInstance

Scaling instance quota exceeded.

The maximum number of ECS instances that is allowed has been reached.

400

QuotaExceeded.AfterpayInstance

Living afterpay instance quota exceeded.

The maximum number of pay-as-you-go ECS instances that is allowed has been reached.

400

ResourceNotAvailable.ECS

The specified region or zone does not offer the specified disk or instance category.

The ECS instances of the specified instance type or disk category cannot be created in the specified region.

400

ScalingRule.InvalidScalingRuleType

Specific scaling rule type: %s can not be executed.

The specified type of scaling rule cannot be executed.

400

InvalidStepAdjustments.NoStepFound

No adjustment step found for a metric value of: %s.

No matching adjustment steps are found for the specified metric.

400

MissingParameter.MetricValue

Metric value must be specified for StepScalingRule.

No metric value is specified for the step scaling rule.

400

MissingParameter.BreachThreshold

Breach threshold must be specified for StepScalingRule.

No threshold is specified for the step scaling rule.

400

BreachThresholdBeyondPermitRange

Specific parameter "%s" beyond permit range.

The specified threshold is invalid.