ScaleWithAdjustment

更新时间:
复制 MD 格式

Unlike the ExecuteScalingRule API, you can use the ScaleWithAdjustment API to trigger elastic scaling based on a specified adjustment rule, without first creating a scaling rule.

Operation description

  • Ensure the following conditions are met before calling this operation:
    • The scaling group is in the Active state.

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

  • This operation bypasses the cooldown to immediately execute a scaling activity, provided no other scaling activities are in progress.

  • If adding the specified ECS instances would cause the total capacity to exceed the maximum size, Auto Scaling sets the total capacity to the maximum size.

  • If removing the specified ECS instances would reduce the total capacity below the minimum size, Auto Scaling sets the total capacity to the minimum size.

A successful response indicates that the API request was accepted, but this does not guarantee that the scaling activity will succeed. You must use the returned ScalingActivityId to check the status of the scaling activity.

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 method used to adjust the number of instances in a 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 scaling group to a specified number.

QuantityChangeInCapacity

AdjustmentValue

integer

Yes

The adjustment value for the scaling activity. A single adjustment cannot add or remove more than 1,000 ECS instances. The valid range depends on AdjustmentType:

  • 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

A client-generated token to ensure the idempotence of the request. This token must be a unique string of up to 64 ASCII characters.

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

SyncActivity

boolean

No

Specifies whether to execute the scaling activity synchronously. This parameter applies only to scaling groups that are configured with an expected number of instances. Valid values:

  • true: Synchronous execution. The scaling activity is triggered immediately.

  • false: Asynchronous execution. The call updates the expected number of instances without immediately triggering the scaling activity. The activity occurs when the system detects a discrepancy between the new expected number and the current number of instances.

Note

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

Default value: false.

false

ParallelTask

boolean

No

Specifies whether the current scaling activity supports concurrency.

false

Overrides

object

No

The parameters to override when scaling out an ECI scaling group.

Cpu

number

No

The number of vCPUs for the instance. Unit: cores.

2

Memory

number

No

The memory size for the instance. Unit: GiB.

4

ContainerOverrides

array<object>

No

A list of container-specific overrides.

array<object>

No

Specifies the overrides for a single container.

Name

string

No

The name of the container to override. The override takes effect only if this name matches a container name in the scaling configuration.

container-1

Args

array

No

The arguments for the container's startup command. You can specify up to 10 arguments.

string

No

A single startup command argument.

arg

Commands

array

No

The container's startup command, specified as an array of strings. You can specify up to 20 strings, and each can be up to 256 characters long.

string

No

A single string in the command array.

sleep

EnvironmentVars

array<object>

No

Environment variables to set in the container.

object

No

A single environment variable, specified as a key-value pair.

Key

string

No

The name of the environment variable. It must be 1 to 128 characters long, cannot start with a digit, and can contain only letters (a-z, A-Z), digits (0-9), and underscores (_).

PATH

Value

string

No

The value of the environment variable, up to 256 characters long.

/usr/local/tomcat

Cpu

number

No

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

2

Memory

number

No

The memory size for the container. Unit: GiB.

4

UserData

string

No

The user data for the ECS instance. It must be Base64-encoded, and the raw data cannot exceed 32 KB.

ZWNobyBoZWxsbyBlY3Mh

LifecycleHookContext

object

No

The lifecycle hook context.

DisableLifecycleHook

boolean

No

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

  • true: Disables all lifecycle hooks.

  • false: Does not disable lifecycle hooks.

false

IgnoredLifecycleHookIds

array

No

A list of lifecycle hook IDs to ignore during the scaling activity.

string

No

The ID of a lifecycle hook to ignore.

ash-bp14zolna43z266bq***

LifecycleHookResult

string

No

ActivityMetadata

string

No

The metadata for the scaling activity.

{"key":"value"}

ExecutionMode

string

No

The execution mode. Valid values:

  • None: Executes a standard scaling activity.

  • PlanOnly: Only performs elastic planning and returns the results in PlanResult without triggering the scaling activity. The results include details such as instance types, availability zones, billing methods, and the number of new instances.

Default value: None.

PlanOnly

Response elements

Element

Type

Description

Example

object

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 this parameter is set to CapacityChange, the scaling activity only adjusts the desired capacity of the scaling group without immediately adding or removing instances.

This setting only affects scaling groups with a configured desired capacity.

CapacityChange

PlanResult

object

The scaling plan result returned when ExecutionMode is set to PlanOnly.

ResourceAllocations

array<object>

The resource allocation details in the scaling plan result.

object

ZoneId

string

The availability zone ID.

cn-beijing-g

InstanceType

string

The instance type.

ecs.u1-c1m8.large

SpotStrategy

string

The spot strategy of the instance. Valid values:

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

  • SpotWithPriceLimit: A spot instance with a user-specified price limit.

  • SpotAsPriceGo: A spot instance where the system automatically bids based on the current market price.

NoSpot

Amount

integer

The number of instances.

1

InstanceChargeType

string

The billing method of the instance. Valid values:

  • 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

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.