All Products
Search
Document Center

Server Load Balancer:Create and manage ALB server groups

Last Updated:Jan 15, 2024

You must create a server group and add one or more backend servers to the server group before you can use Application Load Balancer (ALB). After you complete these tasks, the specified backend servers can receive requests distributed by ALB. By default, ALB uses the ports and protocols that you specify for server groups to distribute requests to the specified backend servers.

Prerequisites

Create a server group

  1. Log on to the ALB console.
  2. In the top navigation bar, select the region where you want to create a server group.

  3. In the left-side navigation pane, choose ALB > Server Groups.

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

  5. In the Create Server Group dialog box, configure the following parameters and click Create.

  6. Parameter

    Description

    Server Group Type

    Specify how backend servers are added to a server group. Valid values:

    • Server: Backend servers are added by specifying ECS instances.

    • IP: Backend servers are added by specifying IP addresses.

    • Function Compute: Backend servers are added by specifying functions.

    Server Group Name

    Enter a name for the server group.

    VPC

    Select a VPC from the VPC drop-down list. Only servers in the VPC can be added to the server group.

    Note

    This parameter is unavailable for server groups of the Function Compute type.

    Backend Server Protocol

    Select a backend protocol. Valid values:

    • HTTP: This is the default value. If you select this option, you can associate the server group with HTTPS, HTTP, and QUIC listeners.

    • HTTPS: If you select this option, you can associate the server group with HTTPS listeners.

    • gRPC: If you select this option, you can associate the server group with HTTPS listeners.

    Note
    • You can associate only server groups that use HTTPS or gRPC with HTTPS listeners of basic ALB instances.

    • This parameter is unavailable for server groups of the Function Compute type.

    Scheduling Algorithm

    Select a scheduling algorithm. Valid values:

    • Weighted Round-robin: Backend servers that have higher weights receive more requests than backend servers that have lower weights.

    • Weighted Least Connections: Requests are forwarded based on the weights and the number of connections to backend servers. If two backend servers have the same weight, the backend server that has fewer connections receives more requests.

    • Consistent Hash: Requests from the same source IP address are forwarded to the same backend server.

      Hash Factor: Select a hash factor.

      • Source IP: Requests from the same source IP address are forwarded to the same backend server.

      • URL Parameter: Requests for the same URL are forwarded to the same backend server. If you select this operation, specify the Specified URL parameter.

    Note

    This parameter is unavailable for server groups of the Function Compute type.

    IPv6 Support

    Specify whether to enable IPv6. IPv6 is disabled by default.

    • If you enable IPv6, you can add IPv4 and IPv6 backend servers to the server group. You can set Server Group Type only to Server.

    • If you disable IPv6, you can add only IPv4 backend servers to the server group. You can set Server Group Type to Server, IP, or Function Compute.

    Note
    • If IPv6 is disabled for the VPC of the server group, you cannot enable IPv6.

    • This parameter is unavailable for server groups of the IP and Function Compute types.

    • When you create a listener for an IPv4 ALB instance, you cannot add server groups for which IPv6 is enabled.

    Session Persistence

    Specify whether to enable session persistence. If session persistence is enabled, ALB forwards all requests from a client to the same backend server.

    • Cookie Option: Select a method to handle cookies.

      • Insert Cookie: ALB inserts a session cookie (SERVERID) into the first HTTP or HTTPS response that is sent to a client. Subsequent requests to ALB carry this cookie, and ALB determines the destination servers of the requests based on the cookie.

      • Rewrite Cookie: When ALB detects a user-defined cookie, ALB replaces the original cookie with the user-defined cookie. Subsequent requests to ALB carry this user-defined cookie, and ALB determines the destination servers of the requests based on the cookie.

    • Session Persistence Timeout Period: Specify the timeout period of session persistence. Valid values: 1 to 86400. Unit: seconds.

    Note

    This parameter is unavailable for server groups of the Function Compute type.

    Persistent Connection

    Specify whether to enable the persistent TCP connection feature.

    After this feature is enabled, a specific number of TCP connections are kept alive between ALB and the backend servers. When the ALB instance receives a new request and an idle persistent TCP connection exists, ALB preferentially uses the TCP connection to forward the request to the backend servers. This reduces the number of TCP handshakes and the loads of the backend servers.

    Note

    This parameter is unavailable for server groups of the Function Compute type.

    Resource Group

    Select the resource group to which the ALB instance belongs.

    Tag

    Configure the Tag Key and Tag Value parameters.

    Health Check

    Specify whether to enable health checks.

    Health Check Settings

    If you enable health checks, you can click Modify on the right side of Health Check Setting to show more health check settings.

    Select and Load Health Check

    Select and load a health check.

    Note
    • When you create a health check, you do not need to specify a server group or a listener. You can associate the health check with a server group or a listener after the health check is created.

    • You can configure only one health check for each backend server.

    Health Check Protocol

    Select the protocol of the health check. For more information about the limits on HTTPS health checks, see Limits on HTTPS health checks.

    • HTTP: ALB performs HTTP health checks by sending HEAD or GET requests to a backend server to check whether the backend server is healthy.

    • HTTPS: ALB performs HTTPS health checks by sending HEAD or GET requests to a backend server to check whether the backend server is healthy. For more information, see the Limits on HTTPS health checks section of this topic.

    • TCP: ALB performs TCP health checks by sending SYN packets to a backend server to check whether the port of the backend server is available to receive requests.

    • gRPC: ALB performs gRPC health checks by sending POST 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:

    • HEAD: By default, HTTP health checks use the HEAD method. 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.

    • POST: By default, gRPC health checks use the POST method. Make sure that your backend servers support POST requests. If your backend servers do not support the POST method or the POST method is disabled, the health check may fail. In this case, you can use the GET method.

    • GET: If the size of a response exceeds 8 KB, the response is truncated. The results of the health check are not affected.

    Note
    • This parameter takes effect only if the Health Check Protocol parameter is set to HTTP, HTTPS, or gRPC.

    • HTTP and HTTPS health checks support the HEAD and GET health check methods. gRPC health checks support the POST and GET health check methods.

    Health Check Protocol Version

    Select an HTTP version. Valid values: HTTP1.0 and HTTP1.1.

    Note

    This parameter is effective only if HTTP or HTTPS is specified as the health check protocol.

    Health Check Port

    Specify the ports on which you want to perform health checks.

    • Backend Server Port: ALB uses the ports of backend servers to perform health checks. This is the default value.

    • Custom Port: ALB uses a specified port to perform health checks. Valid values: 1 to 65535.

    Health Check Path

    Enter the URL of the health check page. The URL must be 1 to 80 characters in length, and can contain letters, digits, hyphens (-), forward slashes (/), periods (.), percent signs (%), question marks (?), number signs (#), and ampersands (&). The URL can also contain the following extended characters: _ ; ~ ! ( ) * [ ] @ $ ^ : ' , +. The path must start with a forward slash (/).

    Health Check Domain Name

    Enter the domain name that is used for health checks.

    • Backend Server Internal IP: The private IP addresses of backend servers are used for health checks. This is the default value.

    • Custom Domain Name: Enter a domain name. The domain name must be 1 to 80 characters in length and can contain only lowercase letters, digits, periods (.), and hyphens (-). The domain name must contain at least one period (.), but cannot start or end with a period (.).

    Health Check Status Codes

    Select one or more HTTP status codes. The specified HTTP status codes are used to indicate that a backend server passes a health check.

    • If the health check protocol is set to HTTP or HTTPS, you can select http_2xx, http_3xx, http_4xx, and http_5xx. http_2xx and http_3xx are selected by default.

    • If you set the Health Check Protocol parameter to gRPC, the valid values are 0 to 99. Value ranges are supported. You can enter up to 20 value ranges and must separate value ranges with commas (,).

    Note

    This parameter takes effect only if HTTP, HTTPS, or gRPC is specified as the health check protocol.

    Response Timeout Period

    Specify the timeout period of a health check response. If a backend server does not respond within the specified timeout period, the 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 health checks before it is declared healthy.

    Unhealthy Threshold

    Specify the number of times that a healthy backend server must consecutively fail health checks before it is declared unhealthy.

    Save the health check configurations as a template, which can facilitate health check creation and configurations

    You can select the check box to save the health check template. If you select this option, you must enter a name for the template.

    Note

    This parameter takes effect only when you set the Select and Load Health Check parameter to Custom Health Check.

Add backend servers

After you create a server group, you must add one or more backend servers to the server group. Then, the specified backend servers can receive requests distributed by ALB.

Add backend servers of the Server type

If you set the server group type to Server, you must add backend servers by specifying ECS instances, elastic network interfaces (ENIs), or elastic container instances.

  1. Log on to the ALB console.
  2. In the left-side navigation pane, choose ALB > Server Groups.

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

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

  5. In the Add Backend Server panel, select a type of cloud service and click Next.

    • ECS instances

      Select ECS/ENI for Server Type and select the ECS instances that you want to add.

      If no ECS instance is available, click Buy ECS in the upper-right corner of the instance list.

    • ENIs

      1. Select ECS/ENI for Server Type 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 Associate an ENI.

        • If no ECS instance is available, 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. Do not add job-optimized elastic container instances as backend servers because ALB does not support job-optimized elastic container instances.

  6. In the Ports/Weights step, 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. If session persistence is enabled, requests may not be evenly distributed to backend servers.

    You can change the weights of multiple servers by moving the pointer over the 批量操作 icon.

    • If you click Replicate to Below, the weights of all servers listed below the current server are set to the same weight as the current server.

    • If you click Replicate to Above, the weights of all servers listed above the current server are set to the same weight as the current server.

    • If you click Replicate to All, the weights of all servers in the server group are set to the same weight as the current server.

    • If you click Reset next to Weight, the weights of all servers in the server group are reset to the default value.

    Warning

    If you set the weight of a server to 0, the server does not receive requests.

Add backend servers of the Function Compute type

If you set the server group type to Function Compute, you must add functions to receive requests. For more information about how to add functions as backend servers, see Add functions of Function Compute to a server group of ALB.

Note

ALB and Function Compute communicate over the secure internal network of Alibaba Cloud.

  1. Log on to the ALB console.
  2. In the left-side navigation pane, choose ALB > Server Groups.

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

  4. On the Backend Servers tab, click Add Function.

    Note

    You can add only one function of Function Compute to a server group of an ALB instance.

  5. In the Add Backend Server panel, use one of the following methods to add a function and click OK.

    • Add a function by selecting the function

      Parameter

      Description

      Configuration Mode

      Select a mode for adding a backend server.

      Select Service from the drop-down list.

      Services

      Select a Function Compute service. If no services are available, click Create a service to create a Function Compute service. For more information, see Create a function.

      Version

      Select LATEST.

      By default, a newly created service runs only the LATEST version.

      Function

      Select the function that you created from the drop-down list. If no functions are available, click Create a function to create a function. For more information, see Manage functions.

      Description

      Enter a description.

    • Add a function by specifying the Alibaba Cloud Resource Name (ARN)

      Parameter

      Description

      Configuration Mode

      Select a mode for adding a backend server.

      Select ARN from the drop-down list.

      ARN

      Enter the Alibaba Cloud Resource Name (ARN) of the function that you want to add.

      You can copy the ARN of a function on the details page of the function in the Function Compute console. For more information, see Obtain the ARN of a function.

      Description

      Enter a description.

Add backend servers of the IP type

If you set the server group type to IP, you must add IP addresses to receive requests. If you do not enable the remote IP address feature, the IP addresses that you want to add must be within the CIDR block of the current VPC. If you enable the remote IP address feature, you can add IP addresses that are not within the current VPC CIDR block. For more information about how to add backend servers to ALB in a different region, see Specify an ECS instance in a VPC as a backend server of ALB in a different region and Add on-premises servers to an ALB instance within the same region.

Limits:

  • You can add only internal-facing servers and cannot add Internet-facing servers.

  • You cannot add a backend server of the IP type to an ALB instance, a Network Load Balancer (NLB) instance, or a Classic Load Balancer (CLB) instance in the same VPC.

  • Make sure that no loops exist. ALB adds the ALICLOUD-ALB-TRACE HTTP header to each request to detect loops. When a loop is detected, ALB stops forwarding requests to backend servers and returns the 463 status code in case a network storm arises and exhausts all resources.

  • You can use Enterprise Edition transit routers and Express Connect circuits for cross-region forwarding. Basic Edition transit routers are not supported.

  • For the same CEN instance, each region can have only one VPC in which one or more ALB instances use backend servers deployed in different regions.

    image
    • ALB instances in different VPCs within the same region cannot use the same transit router to access backend servers.

      image
    • ALB instances in different VPCs within the same region cannot use different transit routers to access the same backend server.

      image
  • Network traffic between an ALB instance and its backend servers can be routed only based on the system route table. VPC custom route tables are not supported.

  1. Log on to the ALB console.
  2. In the left-side navigation pane, choose ALB > Server Groups.

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

  4. On the Backend Servers tab, click Add IP Address.

  5. In the Add Backend Server panel, enter the IP addresses of backend servers and click Next.

    • If you enable the remote IP address feature, IP addresses that fall into the following CIDR blocks are supported:

      • 10.0.0.0/8

      • 100.64.0.0/10

      • 172.16.0.0/12

      • 192.168.0.0/16

    • If you do not enable the remote IP address feature, only IP addresses that fall into the CIDR block of the VPC in which the server group is created are supported.

    Note

    You can click + Add IP Address to add multiple backend servers.

  6. In the Ports/Weights step, set 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. If session persistence is enabled, requests may not be evenly distributed to backend servers.

    You can change the weights of multiple servers by moving the pointer over the 批量操作 icon.

    • If you click Replicate to Below, the weights of all servers listed below the current server are set to the same weight as the current server.

    • If you click Replicate to Above, the weights of all servers listed above the current server are set to the same weight as the current server.

    • If you click Replicate to All, the weights of all servers in the server group are set to the same weight as the current server.

    • If you click Reset next to Weight, the weights of all servers in the server group are reset to the default value.

    Warning

    If you set the weight of a server to 0, the server does not receive requests.

Remove a backend server

You can remove a backend server from a server group as needed. After the server is removed, the server no longer processes client requests.

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. Log on to the ALB console.
  2. In the left-side navigation pane, choose ALB > Server Groups.

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

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

  5. In the message that appears, click OK.

Modify health checks

You can modify the health check configurations of a server group as needed.

  1. Log on to the ALB console.
  2. In the left-side navigation pane, choose ALB > Server Groups.

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

  4. In the Modify Health Check dialog box, turn on or off Health Check. You can also click Modify next to Health Check Settings to modify the health check parameters.

    Warning
    • After health checks are disabled, ALB no longer checks the health status of the backend servers. If a backend server is down, network traffic cannot be automatically switched to healthy backend servers.

    • If you specify a longer health check interval, more time is required for ALB to detect unhealthy backend servers.

Delete a server group

If a server group is not specified in the forwarding rules that listeners use, you can delete the server group. For more information about how to delete a forwarding rule, see Delete a forwarding rule.

After you delete a server group, the backend servers in the server group are not affected. If you no longer need an ECS instance, you can stop or release the ECS instance. For more information, see Stop an instance or Release an instance.

  1. Log on to the ALB console.
  2. In the left-side navigation pane, choose ALB > Server Groups.

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

  4. In the message that appears, click OK.

References