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

  1. Log on to the NLB console.
  2. In the top navigation bar, select the region of the NLB instance.
  3. In the left-side navigation pane, choose Network Load Balancer (NLB) > Server Groups.
  4. On the Server Groups page, click Create Server Group.
  5. 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:
    • Instance: allows you to add backend servers by specifying ECS instances.
    • IP: allows you to add backend servers by specifying 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.
    • TCP SSL: 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.
    • 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 four factors: source IP address, destination IP address, source port, and destination port. Requests that contain the same information based on the four 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.
    Resource Group Select the resource group to which the server group belongs.
    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 the backend servers failed health checks.

    Connection Draining Timeout: 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.
    Configure Health Check Specify whether to enable health checks.
    Advanced Settings After health checks are enabled, you can modify the 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 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.
    Path Enter the URL path 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: 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 when HTTP is specified as the health check protocol.
    Normal Status Codes Select one or more HTTP status codes. The specified 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 Instance, you must add backend servers by specifying ECS instances, elastic network interfaces (ENIs), or elastic container instances.

  1. On the Server Groups page, use one of the following methods to navigate 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. Then, 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, you can click Buy ECS in the upper-right corner of the instance list.

    • ENIs
      1. Select ECS/ENI and turn on the Advanced Mode switch.
      2. Click the The Show icon 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, you can click Buy ECS in the upper-right corner of the instance 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.

  4. Specify the port and weight of the backend server and click OK.
    The default weight is 100. A server that has a higher weight receives more requests.
    You can change the weight and port of a backend server and then move the pointer over the Batch operation icon to synchronize the change to other 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.
    • Rest:
      • 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.
    Notice 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.

  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 Backend Servers tab, click Add IP Address.
  3. In the Select Servers step of the Add Backend Server panel, enter one or more IP addresses and click Next.
    You can specify multiple ports for an IP address and specify a weight for each port.
  4. In the Ports/Weights step of the panel, set the ports and weights and click OK.
    The default weight is 100. A server that has a higher weight receives more requests.
    You can change the weight and port of a backend server and then move the pointer over the Batch operation icon to synchronize the change to other 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.
    • Rest:
      • 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.
    Notice If you set the weight of a server to 0, the server does not receive requests.

Related operations

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, you can modify the name, scheduling algorithm, session persistence parameters, and connection draining parameters.
Modify a health check
  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 to meet your business requirements.
Remove a backend server You can remove a backend server from a 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 message that appears, 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 remain unchanged. If you no longer need a specified backend ECS instance, you can disable or release the ECS instance.
  1. On the Server Groups page, find the server group that you want to delete and choose More > Delete in the Actions column.
  2. In the message that appears, click OK.