Before you use the Network Load Balancer (NLB) service, you must create a server group and add one or more backend servers to the server group to receive client requests forwarded by NLB. By default, NLB uses the ports and protocols that you specify for server groups to forward requests to specified backend servers. This topic describes how to create and manage a server group.
Prerequisites
- Before you add Elastic Compute Service (ECS) instances to a server group, make sure that ECS instances are created and applications are deployed on the ECS instances to receive requests forwarded by NLB.
- To forward requests to the backend servers in a server group, make sure that the server group is specified when you create a listener or when you add a forwarding rule to a listener. For more information, see Overview of NLB listeners.
Create a server group
- Log on to the NLB console.
- In the top navigation bar, select the region where the NLB instance is deployed.
- In the left-side navigation pane, choose .
- On the Server Groups page, click Create Server Group.
- In the Create Server Group dialog box, set the following parameters, and click Create.
Parameter Description Server Group Type Select a server group type. Valid values: - Server Type: allows you to add backend servers by specifying ECS instances, elastic network interfaces (ENIs), or elastic container instances.
- IP: allows you to add backend servers by specifying IP addresses.
Note When you add backend servers by specifying IP addresses, you can specify only private IP addresses. You cannot specify public IP addresses.Server Group Name Enter a name for the server group. VPC Select a VPC from the drop-down list. Backend Server Protocol Select a backend protocol. Valid values: - TCP: If you select this option, you can associate the server group with a TCP listener.
- UDP: If you select this option, you can associate the server group with a UDP listener.
- SSL over TCP: If you select this option, you can associate the server group with a listener that uses SSL over TCP.
Scheduling Algorithm Select a scheduling algorithm. Valid values: - Round-Robin: Requests are forwarded to backend servers in sequence.
- Weighted Round-Robin (default): Backend servers that have higher weights receive more requests than backend servers that have lower weights.
- Source IP Hashing: Requests from the same source IP address are forwarded to the same backend server.
- Four-Element Hashing: specifies consistent hashing that is based on the following factors: source IP address, destination IP address, source port, and destination port. Requests that contain the same information based on the preceding factors are forwarded to the same backend server.
- QUIC ID Hashing: Requests that contain the same QUIC ID are forwarded to the same backend server. Note You can select the QUIC ID hashing algorithm only when the backend protocol is UDP.
IPv6 Support Specify whether to enable IPv6. - If you enable IPv6, you can add IPv4 and IPv6 backend servers to the server group.
- If you do not enable IPv6, you can add only IPv4 backend servers to the server group.
Note If IPv6 is disabled for the VPC that you select for the server group, IPv6 is disabled for the server group by default.Enable Connection Draining After connection draining is enabled, connections to backend servers remain open during the specified timeout period even if the backend servers are removed or if the backend servers fail health checks. Connection Draining Timeout Period: If you enable connection draining, you must specify a timeout period.
Client IP Preservation Specify whether to preserve client IP addresses. After client IP preservation is enabled, backend servers can retrieve client IP addresses. Note You cannot enable client IP preservation for a server group of the IP type. If you want the server group to retrieve client IP addresses, enable Proxy Protocol for the associated listener.Enable All-port Forwarding Specify whether to enable all-port forwarding. After you enable all-port forwarding, you do not need to specify a port when you add a backend server. The NLB instance forwards requests to a backend server based on the frontend port. Note If you enable Listen by Port Range for your listeners, you must enable this feature for the backend server group.Configure Health Check Specify whether to enable health checks. Advanced Settings After health checks are enabled, you can modify Advanced Settings based on your business requirements. Health Check Protocol Select a health check protocol. Valid values: - TCP (default): To perform TCP health checks, NLB sends SYN packets to a backend server to check whether the port of the backend server is available to receive requests.
- HTTP: To perform HTTP health checks, NLB sends HEAD or GET requests to a backend server to check whether the backend server is healthy.
Health Check Method Select a health check method. Valid values: - GET: If the size of a response exceeds 8 KB, the response is truncated. However, the results of the health check are not affected.
- HEAD: HTTP health checks use the HEAD method by default. Make sure that your backend servers support HEAD requests. If your backend servers do not support the HEAD method or the HEAD method is disabled, the health check may fail. In this case, you can use the GET method.
Note This parameter takes effect only when HTTP is specified as the health check protocol.Health Check Port Specify the ports that are probed by health checks. - Backend Server Port: By default, the ports of backend servers are used for health checks.
- Custom Port: Specify a port for health checks.
Note If all-port forwarding is enabled, you must specify a port for health checks.Health Check Path Enter the URL of the health check page. Note This parameter takes effect only when HTTP is specified as the health check protocol.Health Check Domain Name Enter a domain name that is used for health checks. - Backend Server Internal IP (default): The internal IP addresses of backend servers are used as the domain names for health checks.
- Custom Domain Name: Enter a domain name.
Note This parameter takes effect only when HTTP is specified as the health check protocol.Health Check Status Codes Select one or more HTTP status codes. The HTTP status codes are used to indicate that the health check is passed. Valid values: http_2xx (default), http_3xx, http_4xx, and http_5xx.Note This parameter takes effect only when HTTP is specified as the health check protocol.Response Timeout Period Specify a timeout period for a health check response. If a backend server does not respond within the specified timeout period, the backend server fails the health check. Health Check Interval Specify the interval between two consecutive health checks. Healthy Threshold Specify the number of times that an unhealthy backend server must consecutively pass the health check before it is declared healthy. Unhealthy Threshold Specify the number of times that a healthy backend server must consecutively fail the health check before it is declared unhealthy.
Add backend servers by specifying ECS instances, ENIs, or elastic container instances
If you set the server group type to Server Type, you must add backend servers by specifying ECS instances, ENIs, or elastic container instances. You cannot add the same ECS instance, ENI, or elastic container instance to a server group for which all-port forwarding is enabled.
- On the Server Groups page, use one of the following methods to go to the Backend Servers page:
- Find the server group that you want to manage and click Modify Backend Server in the Actions column.
- Find the server group that you want to manage and click the server group ID. On the details page, click the Backend Servers tab.
- On the Backend Servers tab, click Add Backend Server.
- In the Add Backend Server panel, select one of the following types of servers and click Next.
- ECS instances
Select ECS/ENI and select the ECS instances that you want to add.
If no ECS instance is available, click Purchase ECS Instance in the upper-right corner of the ECS instance list.
- ENIs
- Select ECS/ENI and turn on Advanced Mode.
- Click the
icon next to the ID of an ECS instance and select an ENI.
- Make sure that the ENI is attached to the ECS instance. For more information about how to attach a secondary ENI to an ECS instance, see Bind an ENI.
- If no ECS instance is available, click Purchase ECS Instance in the upper-right corner of the ECS instance list.
- Elastic container instances
Select ECI from the Server Type drop-down list and select the elastic container instances that you want to add.
If no elastic container instance is available, click Purchase Elastic Container Instance in the upper-right corner of the list.
- ECS instances
- Specify the ports and weights of the backend servers and click OK. The default weight is 100. A server that has a higher weight receives more requests.Note If all-port forwarding is enabled for a server group, you do not need to specify a port when you add a backend server. NLB forwards requests to the backend server based on the frontend port.You can move the pointer over the
icon to change the weights and ports of multiple servers.
- If you click Replicate to Below, the weights and ports of all servers below the current server are set to the weight and port of the current server.
- If you click Replicate to Above, the weights and ports of all servers above the current server are set to the weight and port of the current server.
- If you click Replicate to All, the weights and ports of all servers in the server group are set to the weight and port of the current server.
- Reset:
- If you click Reset next to Weight, the weights of all servers in the server group are reset to the default value.
- If you click Reset next to Port, the ports of all servers in the server group are cleared.
Warning If you set the weight of a server to 0, the server does not receive requests.
Add backend servers by specifying IP addresses
If you set the server group type to IP, you must add IP addresses to receive requests. You cannot add the same IP address to a server group for which all-port forwarding is enabled.
- On the Server Groups page, use one of the following methods to add an IP address:
- Find the server group that you want to manage and click Modify Backend Server in the Actions column.
- Find the server group that you want to manage and click its ID.
- On the details page of the server group, click the Backend Servers tab and click Add IP Address.
- On the Select Servers tab of the Add Backend Server panel, enter an IP address and click Next. You can specify multiple ports for an IP address and specify a weight for each port.
- On the Ports/Weights tab, specify the ports and weights of IP addresses, and then click OK. The default weight is 100. A server that has a higher weight receives more requests.Note If all-port forwarding is enabled for a server group, you do not need to specify a port when you add a backend server. NLB forwards requests to the backend server based on the frontend port.You can move the pointer over the
icon to change the weights and ports of multiple servers.
- If you click Replicate to Below, the weights and ports of all servers below the current server are set to the weight and port of the current server.
- If you click Replicate to Above, the weights and ports of all servers above the current server are set to the weight and port of the current server.
- If you click Replicate to All, the weights and ports of all servers in the server group are set to the weight and port of the current server.
- Reset:
- If you click Reset next to Weight, the weights of all servers in the server group are reset to the default value.
- If you click Reset next to Port, the ports of all servers in the server group are cleared.
Warning If you set the weight of a server to 0, the server does not receive requests.
More operations
Operation | Procedure |
Modify the basic information about a server group |
|
Modify health check settings |
Warning
|
Remove a backend server | You can remove a backend server from a server group. Warning If you remove a backend server from a server group, your services may be interrupted. We recommend that you set the weight of the backend server to 0 before you remove the backend server from the server group.
|
Delete a server group | You can delete a server group when you no longer need it. After you delete a server group, the status of the specified backend servers remains unchanged. If you no longer need a specified backend ECS instance, ENI, or elastic container instance, you can disable or release the ECS instance, ENI, or elastic container instance.
|
References
- CreateServerGroup: creates a server group for an NLB instance.
- DeleteServerGroup: deletes a server group for an NLB instance.
- AddServersToServerGroup: adds backend servers to a server group of an NLB instance.
- RemoveServersFromServerGroup: removes backend servers from a server group of an NLB instance.
- UpdateServerGroupAttribute: modifies the configurations of a server group of an NLB instance.