You can call this operation to rebalance the distribution of ECS instances in a multi-zone scaling group.

Description

When rebalancing, Auto Scaling starts new instances before terminating the old ones. This ensures that the performance and availability of your application are not compromised by rebalancing instances.

  • You can only call this operation when you set the MultiAZPolicy parameter of the multi-zone scaling group to BALANCE.
  • You can call this operation only when the distribution of instances in the scaling group is significantly imbalanced.
  • A single rebalance operation can redistribute a maximum of 20 ECS instances.
  • If the number of ECS instances in the scaling group approaches or reaches the maximum instance limit (MaxSize) during the rebalancing operation and you must continue rebalancing, the system allows the number of ECS instances to temporarily exceed the limit by 10%, and the number of ECS instances to temporarily exceed by at least 1. This state ends when the rebalancing operation ends, which lasts one to six minutes in most cases.

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 AG6CQdPU8OKdwLjgZcJ****

The ID of the scaling group.

Action String Yes RebalanceInstances

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

Response parameters

Parameter Type Example Description
RequestId String 473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E

The ID of the request.

ScalingActivityId String asa-kjgffgdfadah****

The ID of the scaling activity.

Examples

Sample requests


http://ess.aliyuncs.com/?Action=RebalanceInstances
&ScalingGroupId=AG6CQdPU8OKdwLjgZcJ****
&<Common request parameters>

Sample success responses

XML format

<RebalanceInstancesResponse>
      <RequestId>473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E</RequestId>
      <ScalingActivityId>asa-kjgffgdfadah****</ScalingActivityId>
</RebalanceInstancesResponse>

JSON format

{
	"RequestId":"473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E",
	"ScalingActivityId":"asa-kjgffgdfadah****"
}

Error codes

For more information about error codes, visit API Error Center.

HTTP status code

Error code

Error message

Description

400

IncorrectScalingGroupStatus

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

The error message returned because you have not enabled the specified scaling group.

400

OperationDenied

This operation is denied because the specified scaling group does not support this action.

The error message returned because the MultiAZPolicy parameter of the specified scaling group is not set to Balance, or because the distribution of ECS instances is not sufficiently imbalanced to call this operation.

403

Forbidden.Unauthorized

A required authorization for the specified action is not supplied.

The error message returned because you are not authorized to call the specified operation.

404

InvalidScalingGroupId.NotFound

The specified scaling group does not exist.

The error message returned because the specified scaling group does not exist in the current account.