All Products
Search
Document Center

Auto Scaling:ScaleWithAdjustment

Last Updated:Nov 04, 2025

Scales instances. The ScaleWithAdjustment operation differs from the ExecuteScalingRule operation because ScaleWithAdjustment lets you directly scale instances without creating a scaling rule in advance.

Usage notes

  • Before you call this operation, make sure that the following requirements are met:

    • The scaling group is in the Active state.

    • The scaling group has no scaling activities in progress.

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

  • If adding a specific number of Elastic Compute Service (ECS) instances to the scaling group causes the total number of ECS instances to exceed the maximum limit, Auto Scaling adds ECS instances until the total number reaches the maximum limit.

  • If removing a specific number of ECS instances from the scaling group causes the total number of ECS instances to fall below the minimum limit, Auto Scaling removes ECS instances until the total number reaches the minimum limit.

A successful call indicates that Auto Scaling accepted the request. However, this does not guarantee a successful scaling activity. You can check the status of the scaling activity using the ScalingActivityId returned 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 of the operation 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 a specific number of ECS instances to or removes a specific number of ECS instances from the scaling group.

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

  • TotalCapacity: adjusts the number of ECS instances in the scaling group to a specific 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. Otherwise, the operation fails. Valid values based on the AdjustmentType value:

  • QuantityChangeInCapacity: -1000 to 1000.

  • PercentChangeInCapacity: -100 to 10000.

  • 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 value, but you must make sure that it 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 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 overrides that allow you to adjust the scaling group of the Elastic Container Instance type during a scale-out.

Cpu

Float

No

2

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

Memory

Float

No

4

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

ContainerOverride

Array

No

The list of parameters that you want to use to override specific configurations for containers.

Command

Array of String

No

sleep

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

Memory

Float

No

4

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

Arg

Array of String

No

arg

The arguments that correspond to the startup commands of the container. You can specify up to 10 arguments.

Cpu

Float

No

2

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

EnvironmentVar

Array

No

The information about the environment variables.

Value

String

No

/usr/local/tomcat

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

Key

String

No

PATH

The name of the environment variable. The name can be 1 to 128 characters in length, and can contain letters, underscores (_), and digits. The name cannot start with a digit. Specify the value in the [0-9a-zA-Z] format.

Name

String

No

container-1

The container name. 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.

LifecycleHookContext

Object

No

The context of the lifecycle hook.

DisableLifecycleHook

Boolean

No

false

Specifies whether to disable the Lifecycle Hook feature. Valid values:

  • true: disables the feature.

  • false: does not disable the feature.

IgnoredLifecycleHookIds

Array of String

No

ash-bp14zolna43z266bq***

The IDs of the lifecycle hooks that you want to disable.

ActivityMetadata

String

No

{"key":"value"}

The metadata of the scaling activity.

ExecutionMode

String

No

PlanOnly

The execution mode of the deployment. Valid values:

  • None: No mode is specified. Normal scaling is performed.

  • PlanOnly: No scaling is triggered. Only elastic planning is performed. The planning results are returned in PlanResult, including instance type, zone ID, billing method, and the number of instances to be created.

Default value: None.

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 specified by ScalingActivityId and no scale-out is triggered.

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

PlanResult

Object

The elastic planning results returned when ExecutionMode is set to PlanOnly.

ResourceAllocations

Array of resourceAllocationModels

The resource allocation information in the elastic planning results.

ZoneId

String

cn-beijing-g

The zone ID.

InstanceChargeType

String

Postpaid

The billing method. Valid values:

  • Prepaid: subscription.

  • Postpaid: pay-as-you-go.

Amount

Integer

1

The total number of instances.

InstanceType

String

ecs.u1-c1m8.large

The instance type.

SpotStrategy

String

NoSpot

The instance bidding policy. Valid values:

  • NoSpot: The instances are created as regular pay-as-you-go instances.

  • SpotWithPriceLimit: The instances are created as preemptible instances that have a user-defined maximum hourly price.

  • SpotAsPriceGo: The instances are created as preemptible instances for which the market price at the time of purchase is used as the bid price.

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":["arg"],"Command":["sleep"],"EnvironmentVar":[{"Key":"PATH","Value":"/usr/local/tomcat"}],"Cpu":2.0,"Memory":4.0}]}
&LifecycleHookContext={"DisableLifecycleHook":false,"IgnoredLifecycleHookIds":["ash-bp14zolna43z266bq***"]}
&ActivityMetadata={"key":"value"}
&<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, visit the Error Center.

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 to which the specified scaling rule belongs 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 to which the specified scaling rule belongs 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 to which the specified scaling rule belongs.

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 to which the specified scaling rule belongs 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 whitelist that manages access to the ApsaraDB RDS instance associated with the scaling group to which the specified scaling rule belongs 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 can be scaled 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 that use the specified 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.