• Elastic Load Balancing

elb
  1. Help Center
  2. Elastic Load Balancing
  3. API Reference
  4. Enhanced Load Balancer APIs
  5. Pool (Backend Server Group)
  6. Adding a Backend Server Group

Adding a Backend Server Group

Function

This API is used to add a backend server group. After multiple backend servers are added to a backend server group, requests are distributed among backend servers based on the load balancing algorithm configured for the backend server group and the weight set for each backend server.

URI

POST /v2.0/lbaas/pools

Constraints

  • Backend server groups using different protocols cannot be added to the same listener.
  • If parameter session-persistence is configured, parameter cookie_name is available only when the value of type is APP_COOKIE.

Request

Table 1 Parameter description

Parameter

Type

Mandatory

Description

pool

Dict

Yes

Specifies the backend server group. For details, see Table 2.

Table 2 pool field description

Parameter

Type

Mandatory

Description

tenant_id

String (255)

No

Specifies the ID of the project where the backend server group is used.

The value must be the same as the value of project_id in the token.

name

String (255)

No

Specifies the backend server group name.

description

String (255)

No

Provides supplementary information about the backend server group.

protocol

String

Yes

Specifies the protocol that the backend server group uses to receive requests.

TCP, UDP, and HTTP are supported.

When a backend server group is added with the listener ID specified, the relationships between the backend server group protocol and the listener protocol are as follows:

  • When the listener protocol is UDP, the backend server group protocol must be UDP.
  • If the listener protocol is TCP, the backend server group protocol must be TCP.
  • When the listener protocol is HTTP or TERMINATED_HTTPS, the backend server group protocol must be HTTP.

lb_algorithm

String

Yes

Specifies the load balancing algorithm of the backend server group.

The value can be one of the following:
  • ROUND_ROBIN: indicates the weighted round robin algorithm.
  • LEAST_CONNECTIONS: indicates the weighted least connection algorithm.
  • SOURCE_IP: indicates the source IP hash algorithm.

When the value is SOURCE_IP, the weights of backend servers in the server group are invalid.

admin_state_up

Bool

No

Specifies the administrative status of the backend server group.

This parameter is reserved and has been not used. The default value is true.

listener_id

Uuid

No

Specifies the ID of the listener associated with the backend server group.

Either listener_id or loadbalancer_id must be specified.

loadbalancer_id

Uuid

No

Specifies the ID of the load balancer associated with the backend server group.

Either listener_id or loadbalancer_id must be specified.

session_persistence

Dict

No

Specifies the sticky session timeout duration. For details, see Table 3.

If the value is null, the sticky session feature is disabled.

Table 3 session_persistence field description

Parameter

Type

Mandatory

Description

type

String

Yes

Specifies the sticky session type.

The value can be one of the following:
  • SOURCE_IP: Requests are distributed based on the source IP address. Requests from the same IP address are sent to the same backend server.
  • HTTP_COOKIE: When the client sends a request for the first time, the load balancer automatically generates a cookie and inserts the cookie into the response message. Subsequent requests are sent to the backend server that processes the first request.
  • APP_COOKIE: When the client sends a request for the first time, the backend server generates a cookie and inserts the cookie into the response message. Subsequent requests are sent to the backend server that processes the first request.

When the protocol of the backend server group is TCP, only SOURCE_IP takes effect. When the protocol of the backend server group is HTTP, HTTP_COOKIE and APP_COOKIE take effect.

cookie_name

String

No

Specifies the cookie name.

This parameter is mandatory when the sticky session type is APP_COOKIE.

persistence_timeout

Int

No

Specifies the sticky session timeout duration.

This parameter is invalid when type is set to APP_COOKIE.

The value range varies depending on the protocol of the backend server group:
  • When the protocol is TCP or UDP, the value ranges from 1 to 60.
  • When the protocol is HTTP, the value ranges from 1 to 1440.

Response

Table 4 Parameter description

Parameter

Type

Description

pool

Dict

Specifies the backend server group. For details, see Table 5.

Table 5 pools field description

Parameter

Type

Description

id

Uuid

Specifies the backend server group ID.

tenant_id

String (255)

Specifies the ID of the project where the backend server group is used.

name

String (255)

Specifies the backend server group name.

description

String (255)

Provides supplementary information about the backend server group.

protocol

String

Specifies the protocol that the backend server group uses to receive requests.

TCP, UDP, and HTTP are supported.

When a backend server group is added with the listener ID specified, the relationships between the backend server group protocol and the listener protocol are as follows:

  • When the listener protocol is UDP, the backend server group protocol must be UDP.
  • If the listener protocol is TCP, the backend server group protocol must be TCP.
  • If the listener protocol is HTTP or TERMINATED_HTTPS, the backend server group protocol must be HTTP.

lb_algorithm

String

Specifies the load balancing algorithm of the backend server group.

The value can be one of the following:
  • ROUND_ROBIN: indicates the weighted round robin algorithm.
  • LEAST_CONNECTIONS: indicates the weighted least connection algorithm.
  • SOURCE_IP: indicates the source IP hash algorithm. When the value is SOURCE_IP, the weights of backend servers in the server group are invalid.

members

List

Lists the IDs of backend servers in the backend server group.

healthmonitor_id

Uuid

Specifies the ID of the health check configured for the backend server group.

admin_state_up

Bool

Specifies the administrative status of the backend server group.

This parameter is reserved and has been not used. The default value is true.

listeners

List

Lists the IDs of listeners associated with the backend server group.

loadbalancers

List

Lists the IDs of load balancers associated with the backend server group.

session_persistence

Dict

Specifies whether to enable the sticky session feature. For details, see Table 6.

Once the sticky session feature is enabled, requests from the same client are sent to the same backend server within the specified period.

When this feature is disabled, the parameter value is null.

Table 6 session_persistence field description

Parameter

Type

Description

type

String

Specifies the sticky session type.

The value can be one of the following:
  • SOURCE_IP: Requests are distributed based on the source IP address. Requests from the same IP address are sent to the same backend server.
  • HTTP_COOKIE: When the client sends a request for the first time, the load balancer automatically generates a cookie and inserts the cookie into the response message. Subsequent requests are sent to the backend server that processes the first request.
  • APP_COOKIE: When the client sends a request for the first time, the backend server generates a cookie and inserts the cookie into the response message. Subsequent requests are sent to the backend server that processes the first request.

When the protocol of the backend server group is TCP, only SOURCE_IP takes effect. When the protocol of the backend server group is HTTP, HTTP_COOKIE and APP_COOKIE take effect.

cookie_name

String

Specifies the cookie name.

This parameter is mandatory when the sticky session type is APP_COOKIE.

persistence_timeout

Int

Specifies the sticky session timeout duration.

This parameter is invalid when type is set to APP_COOKIE.

  • Optional value ranges are as follows:
    • When the protocol of the backend server is TCP or UDP, the value ranges from 1 to 60.
    • When the protocol of the backend server is HTTP, the value ranges from 1 to 1440.

Example

  • Example request 1: Adding a backend server group with the sticky session feature disabled
    POST https://{Endpoint}/v2.0/lbaas/pools 
    
    {
        "pool": {
            "lb_algorithm":"ROUND_ROBIN",
            "loadbalancer_id": "63ad9dfe-4750-479f-9630-ada43ccc8117",
            "protocol":"HTTP"
        }
    }
  • Example response 1
    {
        "pool": {
            "lb_algorithm": "ROUND_ROBIN",
            "protocol": "HTTP",
            "description": "",
            "admin_state_up": true,
            "loadbalancers": [
                {
                    "id": "63ad9dfe-4750-479f-9630-ada43ccc8117"
                }
            ],
            "tenant_id": "601240b9c5c94059b63d484c92cfe308",
            
            "session_persistence": null,
            "healthmonitor_id": null,
            "listeners": [],
            "members": [],
            "id": "4e496951-befb-47bf-9573-c1cd11825c07",
            "name": ""
        }
    }
  • Example request 2: Adding an HTTP backend server group that uses app cookies to maintain sticky sessions
    POST https://{Endpoint}/v2.0/lbaas/pools 
    
    { 
      "pool": { 
        "lb_algorithm": "ROUND_ROBIN", 
        "listener_id": "370fb112-e920-486a-b051-1d0d30704dd3", 
        "protocol": "HTTP", 
        "session_persistence": { 
          "cookie_name": "my_cookie", 
          "type": "APP_COOKIE", 
          "persistence_timeout": 1 
        }, 
        "admin_state_up": true 
      } 
    }
  • Example response 2
    { 
      "pool": { 
        "lb_algorithm": "ROUND_ROBIN", 
        "protocol": "HTTP", 
        "description": "", 
        "admin_state_up": true, 
        "loadbalancers": [ 
          { 
            "id": "6b041b9e-976b-40ba-b075-375be6110b53" 
          } 
        ], 
        "tenant_id": "145483a5107745e9b3d80f956713e6a3", 
        
        "session_persistence": { 
          "cookie_name": "my_cookie", 
          "type": "APP_COOKIE", 
          "persistence_timeout": 1 
        }, 
        "healthmonitor_id": null, 
        "listeners": [ 
          { 
            "id": "370fb112-e920-486a-b051-1d0d30704dd3" 
          } 
        ], 
        "members": [ 
     
        ], 
        "id": "307f8968-9474-4d0c-8434-66be09dabcc1", 
        "name": "" 
      } 
    } 
  • Example request 3: Adding an HTTP backend server group that uses HTTP cookies to maintain sticky sessions
    POST https://{Endpoint}/v2.0/lbaas/pools 
    
    {
        "pool": {
            "lb_algorithm":"ROUND_ROBIN",
            "loadbalancer_id": "63ad9dfe-4750-479f-9630-ada43ccc8117",
            "protocol":"HTTP",
            "session_persistence":{
            	"type":"HTTP_COOKIE"
            }
        }
    }
  • Example response 3
    {
        "pool": {
            "lb_algorithm": "ROUND_ROBIN",
            "protocol": "HTTP",
            "description": "",
            "admin_state_up": true,
            "loadbalancers": [
                {
                    "id": "63ad9dfe-4750-479f-9630-ada43ccc8117"
                }
            ],
            "tenant_id": "601240b9c5c94059b63d484c92cfe308",
            
            "session_persistence": {
                "persistence_timeout": 1440,
                "cookie_name": null,
                "type": "HTTP_COOKIE"
            },
            "healthmonitor_id": null,
            "listeners": [],
            "members": [],
            "id": "d46eab56-d76b-4cd3-8952-3c3c4cf113aa",
            "name": ""
        }
    }

Response Codes

For details, see HTTP Status Codes for Enhanced Load Balancers.