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

Prerequisites

  • Before you add Elastic Compute Service (ECS) instances to a server group, make sure that the ECS instances are created. In addition, applications are deployed on the ECS instances to receive requests that are distributed by ALB.
  • To route traffic to the backend servers in a server group, make sure that the server group is specified when you create a listener or add a forwarding rule to a listener. For more information, see Manage forwarding rules for listeners.

Create a server group

To create a server group, perform the following steps:

  1. Log on to the SLB console.
  2. In the left-side navigation pane, choose ALB > Server Groups.
  3. On the Server Groups page, click Create Server Group.
  4. Set the parameters that are described in the following table and click Create.
    Parameter Description
    Server Group Name Enter a name for the server group. The name must be 2 to 128 characters in length, and can contain letters, digits, periods (.), underscores (_), and hyphens (-). The name must start with a letter.
    VPC Select a virtual private cloud (VPC) from the VPC drop-down list. You can add only the servers that are deployed in the specified VPC to the server group.
    Backend Server Protocol Select a backend protocol. Valid values:
    • HTTP (default): If you select this option, you can associate the backend servers with HTTPS, HTTP, and QUIC listeners.
    • HTTPS: If you select this option, you can associate the backend servers with HTTPS listeners.
    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.
    • Source IP Consistent Hashing: Requests from the same source IP address are distributed to the same backend server.
    Session Persistence Specify whether to enable or disable session persistence. After you enable session persistence, the listener forwards the requests from the same client to a specific backend server.
    Cookie Persistence Select a method to handle the cookie. Valid values:
    • Insert Cookie: ALB inserts a cookie (SERVERID) into the first HTTP or HTTPS response that is sent to a client. The next request from the client contains the cookie. Then, the listener distributes the request to the recorded backend server.
    • Rewrite Cookie: When ALB detects a user-defined cookie, ALB rewrites the original cookie with the user-defined cookie. The next request from the client contains the user-defined cookie, and the listener distributes the request to the recorded backend server.
    Note This parameter takes effect only after the session persistence feature is enabled.
    Session Persistence Timeout Period Enter the timeout period of session persistence. Valid values: 1 to 86400. Unit: seconds.
    Note This parameter takes effect only after the session persistence feature is enabled.
    Configure Health Check Specify whether to enable or disable health checks.
    Advanced Settings
    Select and Load Health Check Select and load a health check.
    Note You do not need to specify a server group or listener when you create a health check. After the health check is created, you can associate it with a server group or listener anytime.
    Protocol Select the protocol of the health check. Valid values:
    • HTTP: HTTP health checks simulate a process that uses a web browser to access resources by sending HEAD or GET requests to an instance. These requests are used to check whether the instance is healthy.
    • TCP: TCP health checks send SYN handshake packets to an instance to check whether the instance is healthy.
    Health Check Method Select a method for the health check. Valid values: HEAD and GET.
    • 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. To resolve this issue, you can use the GET method instead of the HEAD method.
    • GET: If the length of a request exceeds 8 Kb, the request is truncated. However, the health check result is not affected.
    Note This parameter takes effect only when the health check protocol is set to HTTP.
    Protocol Select an HTTP version. Valid values: HTTP1.0 and HTTP1.1.
    Note This parameter takes effect only when the health check protocol is set to HTTP.
    Port Select the port that the health check feature uses to communicate with backend servers.
    • Backend Server Port: By default, the ports of backend servers are used for health checks.
    • Custom Port: Specify a port for health checks. Valid values: 1 to 65535.
    Path Enter the URL of the health check page. The URL must be 1 to 80 characters in length, and can contain letters, digits, and special characters. The URL can contain the following special characters: - / . % ? # & _ ; ~ ! ( ) * [ ] @ $ ^ : ' , +. The URL must start with a forward slash (/).
    Health Check Domain Name Enter the domain name that is used for health checks.
    • Backend Server Internal IP (default): uses the private IP addresses of backend servers as the domain names for health checks.
    • 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 (.). The domain name cannot start or end with a period (.).
    Normal Status Codes Select one or more HTTP status codes. The specified HTTP status codes are used to indicate that health checks are normal. Valid values: http_2xx, http_3xx, http_4xx, and http_5xx. Default value: http_2xx.
    Note This parameter takes effect only when the health check protocol is set to HTTP.
    Response Timeout Period Specify the amount of time to wait for a health check response. If a backend ECS instance does not send an expected response within the specified period of time, the health check fails.

    Valid values: 1 to 300. Default value: 5. Unit: seconds.

    Health Check Interval Specify the interval between two consecutive health checks.

    Valid values: 1 to 50. Default value: 2. Unit: seconds.

    Healthy Threshold Specify the number of times that an unhealthy backend server must consecutively pass health checks before the backend server is declared healthy.

    Valid values: 2 to 10. Default value: 3.

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

    Valid values: 2 to 10. Default value: 2.

    Save Configuration as Template Specify whether to save the health check configuration as a template.

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.

  1. Log on to the SLB console.
  2. In the left-side navigation pane, choose ALB > Server Groups.
  3. On the Server Groups page, find the server group that you created and click Modify Backend Server in the Actions column.
  4. On the Backend Servers tab, click Add Backend Server.
  5. In My Servers panel, specify the type of backend server, select the backend servers that you want to add, and then click Next.
  6. In the Configure Ports and Weights step, specify ports and weights for the backend servers and click Add.
    The default weight is 100. A server with a higher weight receives more requests. If session persistence is enabled, requests may not be evenly distributed to the backend servers.
    You can move the pointer over the Batch icon and perform one of the following actions to change the weights of multiple servers at a time:
    • Click Replicate to Below: The weights of the servers below the current server are set to the weight of the current server.
    • Click Replicate to Above: The weights of the servers above the current server are set to the weight of the current server.
    • Click Replicate to All: The weights of the servers in the server group are set to the weight of the current server.
    • Click Reset next to Weight: The weights of the servers in the server group are reset to the default value.
    Notice After you set the weight of a backend server to 0, no request is distributed to the backend server.
  7. Click Add.

Delete a server group

You can delete a server group if the server group is not specified in any forwarding rules that are used by listeners. After you delete a server group, the backend servers in the server group are not affected. If you no longer need an ECS instance that functions as a backend server, you can stop or release the ECS instance.

  1. Log on to the SLB console.
  2. In the left-side navigation pane, choose ALB > Server Groups.
  3. Find the server group that you want to delete and click Delete in the Actions column.
  4. Click OK.