All Products
Search
Document Center

Server Load Balancer:Create and manage a server group

Last Updated:Jan 29, 2024

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, elastic network interfaces (ENIs), or elastic container instances to a server group, make sure that the resources are created and applications are deployed on the resources to receive requests forwarded by NLB.

  • To forward requests to the backend servers in a server group, specify the server group when you create a listener or a forwarding rule. For more information, see Overview of NLB listeners.

Create a server group

  1. Log on to the NLB console.
  2. In the top navigation bar, select the region in which the NLB instance is deployed.

  3. In the left-side navigation pane, choose NLB > Server Group.

  4. On the Server Group page, click Create Server Group.

  5. In the Create Server Group dialog box, configure 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, 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 operation, you can associate the server group with a TCP listener or a listener that uses SSL over TCP.

    • UDP: If you select this option, you can associate the server group with a UDP listener.

    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: specifies consistent hashing that is based on source IP addresses. Requests from the same source IP address are distributed 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: specifies consistent hashing based on QUIC IDs. Requests with 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.

    Resource Group

    Select a resource group for the server group.

    Tag

    Configure the Tag Key and Tag Value parameters.

    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 they 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. If 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 all-port forwarding for your listener, you must enable this feature for the backend server group.

    Enable Health Check

    Specify whether to enable health checks.

    Health Check Settings

    After health checks are enabled, you can click Modify to modify health check settings.

    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 can 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 an HTTP method that is used for health checks. 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 if HTTP is specified as the health check protocol.

    Health Check Port

    Specify the ports that are probed by health checks.

    • Backend Server Port: Health checks probe the ports of backend servers. This is the default setting.

    • Custom Port: Health checks probe a specified port.

    Note

    If all-port forwarding is enabled, you must specify a specific health check port.

    Health Check Path

    Enter the URL of the health check page.

    Note

    This parameter takes effect only if 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: uses the private IP addresses of backend servers for health checks. This is the default value.

    • Custom Domain Name: Enter a domain name.

    Note

    This parameter takes effect only if HTTP is specified as the health check protocol.

    Health Check Status Codes

    Select one or more HTTP status codes that 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 if 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 is declared unhealthy.

    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.

  1. On the Server Groups page, use one of the following methods to go to the Backend Servers tab:

    • 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.

  2. On the Backend Servers tab, click Add Backend Server.

  3. In the Add Backend Server panel, select a type of cloud service 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 server list.

    • ENIs

      1. Select ECS/ENI and turn on Advanced Mode.

      2. Click the 展开符合 icon next to the ID of an ECS instance and select an ENI.

        • Make sure that the ENI is associated with the ECS instance. For more information about how to associate a secondary ENI with an ECS instance, see Bind an ENI.

        • If no ECS instance is available, click Purchase ECS Instance in the upper-right corner of the server list.

    • Elastic container instances

      Select ECI for Server Type and select an elastic container instance.

      If no elastic container instance is available, click Purchase Elastic Container Instance in the upper-right corner of the instance list. NLB does not support job-optimized elastic container instances as backend servers.

  4. Specify the ports and weights of the backend servers and click OK.

    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.

    The default weight is 100. A server that has a higher weight receives more requests.

    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 duplicate IP addresses to a server group which has all-port forwarding enabled.

Note When you add backend servers by specifying IP addresses, you can specify only private IP addresses. You cannot specify public IP addresses.
  1. On the Server Groups page, use one of the following methods to add IP addresses:

    • 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.

  2. On the details page of the server group, click the Backend Servers tab and click Add IP Address.

  3. 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.

  4. On the Ports/Weights tab, specify the ports and weights of IP addresses, and then click OK.

    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.

    The default weight is 100. A server that has a higher weight receives more requests.

    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.

What to do next

Operation

Procedure

Modify the basic information about a server group

  1. On the Server Groups page, find the server group that you want to manage and click Modify Basic Information in the Actions column.

  2. In the Modify Basic Information dialog box, modify the Server Group Name, Scheduling Algorithm, Enable Connection Draining, and Client IP Preservation parameters.

Modify health check settings

  1. On the Server Groups page, find the server group that you want to manage and click Modify Health Check Settings in the Actions column.

  2. In the Modify Health Check Settings dialog box, you can modify the health check settings to meet your business requirements.

Warning
  • If health checks are disabled, NLB no longer checks backend servers. If a backend server fails, traffic cannot be automatically switched to healthy backend servers.

  • If a longer health check interval is specified, more time is required for NLB to detect unhealthy backend servers.

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.

  1. On the Server Groups page, find the server group that you want to manage and click its ID.

  2. Click the Backend Servers tab, find the backend server that you want to remove and click Remove in the Actions column.

  3. In the Remove Backend Server message, click OK.

Delete a server group

If a server group is not specified in the forwarding rules that listeners use, you can delete the server group. 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.

  1. On the Server Groups page, find the server group that you want to delete and choose 更多 > Delete in the Actions column.

  2. In the Remove Backend Server message, click OK.

References