Adds backend servers.

Note If multiple identical Elastic Compute Service (ECS) instances are specified in a request, only the first ECS instance is added. The other ECS instances are ignored. If the backend server that you add is identical to one of the existing backend servers that are associated with a listener, an error is reported.

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 AddBackendServers

The operation that you want to perform.

Set the value to AddBackendServers.

LoadBalancerId String Yes lb-2ze7o5h52g02kkzz******

The ID of the Server Load Balancer (SLB) instance.

RegionId String Yes cn-beijing

The ID of the region where the SLB instance is deployed.

You can call the DescribeRegions operation to query the most recent region list.

BackendServers String Yes [{ "ServerId": "eni-xxxxxxxxx", "Weight": "100", "Type": "eni", "ServerIp": "192.168.**.**", "Port":"80","Description":"test-112" },{ "ServerId": "eni-xxxxxxxxx", "Weight": "100", "Type": "eni", "ServerIp": "172.166.**.**", "Port":"80","Description":"test-113" }]

The list of backend servers that you want to add. Set the following parameters:

  • ServerId: This parameter is required and the value uses the String type. Enter the ID of the instance that serves as the backend server. If ServerId is set to the ID of an elastic network interface (ENI), Type is required.
  • Weight: The weight of the backend server. Valid values: 0 to 100. Default value: 100.

    If the value is set to 0, no requests are forwarded to the backend server.

  • Description: Optional. Specify the description of the backend server. This parameter must be of the String type. The description must be 1 to 80 characters in length, and can contain letters, digits, hyphens (-), forward slashes (/), periods (.),and underscores (_).
  • Type: The type of backend server. Valid values:
    • ecs: an ECS instance. This is the default value.
    • eni: an ENI.
Note You can specify ENIs as the backend servers of only high-performance instances.
  • ServerIp: The IP address of the ECS instance or ENI.

Examples:

  • Associate an ECS instance:[{ "ServerId": "i-xxxxxxxxx", "Weight": "100", "Type": "ecs", "Port":"80","Description":"test-112" }]
  • Associate an ENI:[{ "ServerId": "eni-xxxxxxxxx", "Weight": "100", "Type": "eni", "ServerIp": "192.168.**.**", "Port":"80","Description":"test-112" }]
  • Associate an ENI with multiple IP addresses:[{ "ServerId": "eni-xxxxxxxxx", "Weight": "100", "Type": "eni", "ServerIp": "192.168.**.**", "Port":"80","Description":"test-112" },{ "ServerId": "eni-xxxxxxxxx", "Weight": "100", "Type": "eni", "ServerIp": "172.166.**.**", "Port":"80","Description":"test-113" }]
Note The backend servers that you add to an SLB instance must be in the Running state. You can add up to 20 backend servers to an SLB instance in each request.

Response parameters

Parameter Type Example Description
LoadBalancerId String lb-2ze7o5h52g02kkzz****

The ID of the SLB instance.

BackendServers Array of BackendServer

The list of backend servers.

BackendServer
ServerId String i-2zej4lxhjoq1icu*****

The ID of the ECS instance or ENI.

Weight String 100

The weight of the backend server.

Valid values: 0 to 100.

Default value: 100. If the value is set to 0, the SLB instance does not forward requests to the backend server.

Description String BackendServer

The description of the backend server.

Type String ecs

The type of the backend server.

  • ecs: an ECS instance. This is the default value.
  • eni: an ENI.
RequestId String 34B82C81-F13B-4EEB-99F6-A048C67CC830

The ID of the request.

Examples

Sample requests

http(s)://[Endpoint]/?Action=AddBackendServers
&RegionId=cn-hangzhou
&LoadBalancerId=lb-2ze7o5h52g02kkzz******
&BackendServers=[{ "ServerId": "eni-xxxxxxxxx", "Weight": "100", "Type": "eni", "ServerIp": "192.168.**.**", "Port":"80","Description":"test-112" },{ "ServerId": "eni-xxxxxxxxx", "Weight": "100", "Type": "eni", "ServerIp": "172.166.**.**", "Port":"80","Description":"test-113" }]
&<Common request parameters>

Sample success responses

XML format

<AddBackendServersResponse>
    <BackendServers>
        <BackendServer>
            <ServerId>i-2zej4lxhjoq1icu*****</ServerId>
            <Weight>100</Weight>
            <Type>ecs</Type>
        </BackendServer>
        <BackendServer>
            <ServerId>i-2ze1u9ywulp5pbv*****</ServerId>
            <Weight>100</Weight>
            <Type>ecs</Type>
        </BackendServer>
    </BackendServers>
    <RequestId>34B82C81-F13B-4EEB-99F6-A048C67CC830</RequestId>
    <LoadBalancerId>lb-2ze7o5h52g02kkzz*****</LoadBalancerId>
</AddBackendServersResponse>

JSON format

{
    "RequestId": "34B82C81-F13B-4EEB-99F6-A048C67CC830",
    "BackendServers": {
        "BackendServer": [
            {
                "ServerId": "i-2zej4lxhjoq1icue****",
                "Weight": 100,
                "Type": "ecs"
            },
            {
                "ServerId": "i-2ze1u9ywulp5pbvv****",
                "Weight": 100,
                "Type": "ecs"
            }
        ]
    },
    "LoadBalancerId": "lb-2ze7o5h52g02kkzze****"
}

Error codes

HttpCode Error code Error message Description
400 InvalidParameter The specified load balancer does not support the network type of the ECS instance. The error message returned because the SLB instance does not support ECS instances of the specified type. Change the type and try again.

For a list of error codes, visit the API Error Center.