All Products
Search
Document Center

Auto Scaling:ScaleWithAdjustment

Last Updated:Sep 10, 2026

Triggers elastic scaling based on a specified adjustment rule.

Operation description

Operation description

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

    • The scaling group is in the Active state.

    • No scaling activity is in progress in the scaling group.

  • If no scaling activity is in progress in the scaling group, this operation can bypass the cooldown time and directly trigger a scaling activity.

  • If the number of ECS instances to be added based on the scaling rule plus the current number of instances in the scaling group (Total Capacity) is greater than the maximum number of instances (MaxSize), the scaling activity is performed with Total Capacity set to MaxSize.

  • If the current number of instances in the scaling group (Total Capacity) minus the number of ECS instances to be removed based on the scaling rule is less than the minimum number of instances (MinSize), the scaling activity is performed with Total Capacity set to MinSize.

A successful response only indicates that Auto Scaling has accepted the request and can perform the scaling activity. It does not mean that the scaling activity will succeed. You can check the execution status of the scaling activity based on the returned ScalingActivityId.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

ess:ScaleWithAdjustment

update

*ScalingGroup

acs:ess:{#regionId}:{#accountId}:scalinggroup/{#scalinggroupId}

None None

Request parameters

Parameter

Type

Required

Description

Example

ScalingGroupId

string

Yes

The ID of the scaling group.

asg-j6c1o397427hyjdc****

AdjustmentType

string

Yes

The adjustment method of the scaling activity. Valid values:

  • QuantityChangeInCapacity: adds or removes a specified number of ECS instances.

  • PercentChangeInCapacity: adds or removes a specified percentage of ECS instances.

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

QuantityChangeInCapacity

AdjustmentValue

integer

Yes

The adjustment value of the scaling activity. The number of ECS instances adjusted in a single scaling activity cannot exceed 1000. Otherwise, the adjustment fails. Valid values for different adjustment methods:

  • QuantityChangeInCapacity: -1000 to 1000.

  • PercentChangeInCapacity: -100 to 10000.

  • TotalCapacity: 0 to 2000.

100

MinAdjustmentMagnitude

integer

No

The minimum number of instances to adjust in a scaling activity. This parameter takes effect only when AdjustmentType is set to PercentChangeInCapacity.

1

ClientToken

string

No

The client token that is used to ensure the idempotence of the request and prevent repeated submissions. The value is generated by the client and must be unique across different requests. The value can be up to 64 ASCII characters in length and cannot contain non-ASCII characters.

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

SyncActivity

boolean

No

Specifies whether to synchronously execute the scaling activity. This parameter is valid only for scaling groups that have the expected number of instances configured. Valid values:

  • true: synchronous execution. The scaling rule directly triggers the scaling activity of the scaling group.

  • false: asynchronous execution. When the expected number of instances in the scaling group is modified, the scaling activity is not immediately triggered. The system waits until it detects a difference between the expected number of instances and the current number of instances in the scaling group, and then triggers the scaling activity.

Note

For more information about the expected number of instances, see Expected number of instances.

Default value: false.

false

Overrides

object

No

The override parameters for scale-out in ECI-type scaling groups.

Cpu

number

No

The number of vCPUs at the instance level. Unit: cores.

2

Memory

number

No

The memory size at the instance level. Unit: GiB.

4

UserData

string

No

ContainerOverride

array<object>

No

The override parameters for the container list.

array<object>

No

The override parameters for the container list.

Command

array

No

The container startup commands. A maximum of 20 commands are supported. Each command can contain up to 256 characters.

string

No

The container startup commands. A maximum of 20 commands are supported. Each command can contain up to 256 characters.

sleep

Memory

number

No

The memory size of the container. Unit: GiB.

4

Arg

array

No

The arguments for the container startup commands. A maximum of 10 arguments are supported.

string

No

The arguments for the container startup commands. A maximum of 10 arguments are supported.

arg

Cpu

number

No

The number of vCPUs of the container. Unit: cores.

2

EnvironmentVar

array<object>

No

The list of environment variable information.

object

No

The list of environment variable information.

Value

string

No

Environment variable value. Length: 0 to 256 characters.

/usr/local/tomcat

Key

string

No

Environment variable name. Length: 1 to 128 characters. Format requirements: [0-9a-zA-Z] and underscores (_); must not start with a digit.

PATH

Name

string

No

The container name. If you want to override container parameters, you must specify the container name. The container parameters can be overridden only when the container name matches the container name in the scaling configuration.

container-1

LifecycleHookContext

object

No

The context information of the lifecycle hook.

DisableLifecycleHook

boolean

No

Specifies whether to disable all lifecycle hook features for the scaling activity. Valid values:

  • true: disabled.

  • false: not disabled.

false

IgnoredLifecycleHookIds

array

No

The list of lifecycle hook IDs to be disabled for the scaling activity.

string

No

The list of lifecycle hook IDs to be disabled for the scaling activity.

ash-bp14zolna43z266bq***

LifecycleHookResult

string

No

ActivityMetadata

string

No

The metadata of the scaling activity.

{"key":"value"}

ExecutionMode

string

No

The execution mode. Valid values:

  • None: not specified. Normal scaling is performed.

  • PlanOnly: scaling is not triggered. Only elastic planning is performed, and 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.

PlanOnly

Response elements

Element

Type

Description

Example

object

The response parameters for triggering elastic scaling based on a specified adjustment rule.

ScalingActivityId

string

The ID of the scaling activity.

asa-bp175o6f6ego3r2j****

RequestId

string

The request ID.

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

ActivityType

string

The type of the scaling activity.

If ActivityType is set to CapacityChange, the scaling activity corresponding to the returned ScalingActivityId only modifies the expected number of instances in the scaling group without immediately performing scaling.

Applicable scope: scaling groups with the expected number of instances configured.

CapacityChange

PlanResult

object

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

ResourceAllocations

array<object>

The resource allocation information in the elastic planning results.

object

ZoneId

string

Zone ID.

cn-beijing-g

InstanceType

string

Instance type.

ecs.u1-c1m8.large

SpotStrategy

string

The spot strategy of the instance. Valid values:

  • NoSpot: A normal pay-as-you-go instance.

  • SpotWithPriceLimit: A spot instance with a specified maximum price.

  • SpotAsPriceGo: A spot instance for which the system automatically bids based on the current marketplace price.

NoSpot

Amount

integer

Number of instances.

1

InstanceChargeType

string

Billing method. Valid return values are as follows:

  • Prepaid: subscription.

  • Postpaid: pay-as-you-go.

Postpaid

Examples

Success response

JSON format

{
  "ScalingActivityId": "asa-bp175o6f6ego3r2j****",
  "RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3****",
  "ActivityType": "CapacityChange",
  "PlanResult": {
    "ResourceAllocations": [
      {
        "ZoneId": "cn-beijing-g",
        "InstanceType": "ecs.u1-c1m8.large",
        "SpotStrategy": "NoSpot",
        "Amount": 1,
        "InstanceChargeType": "Postpaid"
      }
    ]
  }
}

Error codes

HTTP status code

Error code

Error message

Description

403 Forbidden.Forbidden Operation Forbidden

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.