All Products
Search
Document Center

Auto Scaling:ScaleWithAdjustment

更新時間:May 23, 2024

Scales instances. The ScaleWithAdjustment operation differs from the ExecuteScalingRule operation in that ScaleWithAdjust can directly scale instances without requiring you to create a scaling rule in advance.

Usage notes

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

    • The scaling group is in the Active state.

    • The scaling group has no ongoing scaling activities.

  • 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 allowed number, Auto Scaling adds ECS instances to the scaling group until the total number of instances is equal to the maximum allowed number.

  • 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 allowed number, Auto Scaling removes ECS instances from the scaling group until the total number of instances is equal to the minimum allowed number.

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 based on 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 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 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 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. A 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.

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.

Name

String

No

container-1

The container name. If you specify ContainerOverrides, you must also specify Name. ContainerOverrides takes effect only when the container name specified by Name matches that specified in the scaling configuration.

Arg

Array of String

No

arg

The argument that corresponds to the startup command of the container. You can specify up to 10 arguments.

Command

Array of String

No

sleep

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

EnvironmentVar

Array

No

The information about the environment variables.

Key

String

No

PATH

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

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.

LifecycleHookContext

Object

No

The context of the lifecycle hook.

DisableLifecycleHook

Boolean

No

false

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

  • true

  • false

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.

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.

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, see Service error codes.

HTTP status code

Error code

Description

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 load balancer that is attached to 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 load balancer that is attached to 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 load balancer in use 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 load balancer 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 attached to 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 attached to 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 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.