All Products
Search
Document Center

Auto Scaling:AttachServerGroups

更新時間:May 30, 2024

Attaches server groups to a scaling group. To seamlessly adjust the number of instances in response to changes in your business workload or to maintain the uninterrupted accessibility of your application, you can call the AttachServerGroups operation. By attaching Application Load Balancer (ALB) or Network Load Balancer (NLB) server groups to your scaling group, this operation enables Auto Scaling to automatically tailor your computing capacity to your business needs. Furthermore, it optimizes traffic routing by dynamically allocating incoming requests based on current workload patterns, which significantly improves the stability and performance of your application.

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

Action

String

Yes

AttachServerGroups

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

RegionId

String

Yes

cn-hangzhou

The region ID of the scaling group.

ScalingGroupId

String

Yes

asg-bp18p2yfxow2dloq****

The ID of the scaling group.

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 the value is unique among different requests. The token can contain only ASCII characters and cannot exceed 64 characters in length. For more information, see Ensure idempotence.

ForceAttach

Boolean

No

false

Specifies whether to add the existing Elastic Compute Service (ECS) instances or elastic container instances in the scaling group to server group N. Valid values:

  • true

  • false

Default value: false.

ServerGroup.N.ServerGroupId

String

Yes

sgp-60ofsqhwer0b***

The ID of server group N.

ServerGroup.N.Type

String

Yes

ALB

The type of server group N. Valid values:

  • ALB

  • NLB

ServerGroup.N.Weight

Integer

Yes

100

The weight of an ECS instance or elastic container instance as a backend server of server group N. Valid values: 0 to 100.

If you assign a higher weight to an instance, the instance is allocated a larger proportion of access requests. If you assign zero weight to an instance, the instance is allocated no access requests.

ServerGroup.N.Port

Integer

Yes

22

The port used by ECS instances or elastic container instances after being added as backend servers to server group N.

Valid values: 1 to 65535.

Response parameters

Parameter

Type

Example

Description

ScalingActivityId

String

asa-bp1c9djwrgxjyk31****

The ID of the scaling activity. During the scaling activity, server group N is attached to the scaling group and the existing ECS instances or elastic container instances in the scaling group are added to server group N.

Note

This parameter is returned only if you set ForceAttach to true.

RequestId

String

74C4E313-8570-479F-8791-DC25360D****

The request ID.

Examples

Sample requests

http(s)://ess.aliyuncs.com/?Action=AttachServerGroups
&RegionId=cn-hangzhou
&ScalingGroupId=asg-bp18p2yfxow2dloq****
&ClientToken=123e4567-e89b-12d3-a456-42665544****
&ForceAttach=false
&ServerGroup=[{"ServerGroupId":"sgp-60ofsqhwer0b***","Type":"ALB","Weight":100,"Port":22}]
&<Common request parameters>

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<AttachServerGroupsResponse>
    <ScalingActivityId>asa-bp1c9djwrgxjyk31****</ScalingActivityId>
    <RequestId>74C4E313-8570-479F-8791-DC25360D****</RequestId>
</AttachServerGroupsResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "ScalingActivityId" : "asa-bp1c9djwrgxjyk31****",
  "RequestId" : "74C4E313-8570-479F-8791-DC25360D****"
}

Error codes

For a list of error codes, see Service error codes.