Before you can use the Application Load Balancer (ALB) service, you must create a server group and add one or more servers to the group as backend servers. By default, ALB uses the ports and protocols that you specified for server groups to distribute client 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 the server group is deployed.
  3. In the left-side navigation pane, choose ALB > Server Groups.
  4. On the Server Groups page, click Create Server Group.
  5. Set the following parameters and click Create.
    Parameter Description
    Server Group Type Specify how backend servers are added to a server group. Valid values:
    • Instance: 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.
    Note The IP type cannot be selected by default. To create a server group of the IP type, submit a ticket.
    Server Group Name Enter a name for the server group.
    VPC Select a virtual private cloud (VPC) from the VPC drop-down list. Only servers in the specified VPC can be added to the server group.

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

    Backend Server Protocol Select a backend protocol. Valid values:
    • HTTP: The server group is associated with HTTPS, HTTP, and QUIC listeners. This is the default value.
    • HTTPS: The server group is associated with HTTPS listeners.
    • gRPC: The server group is associated with HTTPS and QUIC listeners.
    Note
    • HTTPS listeners of a basic ALB instance can be associated with only server groups that use HTTP.
    • You can select only HTTP 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 those that have lower weights.
    • Weighted Least Connections: Requests are distributed 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 is expected to receive more requests.
    • Consistent Hashing: Requests from the same source IP address are distributed to the same backend server.

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

    Resource Group Select the resource group to which the server group belongs.
    Session Persistence Specify whether to enable session persistence. If session persistence is enabled, ALB forwards all requests from the same client to the same backend server.
    • Cookie Persistence: Select a method to handle session 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 cookies.
      • Rewrite Cookie: When ALB detects a user-defined cookie, ALB rewrites 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 cookies.
    • Session Persistence Timeout Period: Specify the timeout period of session persistence. Valid values: 1 to 86400. Unit: seconds.

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

    Configure Health Check Specify whether to enable health checks.
    Advanced Settings After you enable health checks, you can click Modify next to Advanced Settings to configure 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 health checks. You can associate the health check with a server group or listener after the health check is created.
    • You can configure only one health check for each backend server.
    Protocol Select the protocol of health checks. Valid values:
    • HTTP: To perform HTTP health checks, ALB sends HEAD or GET requests to the backend server to check whether the backend server is healthy.
    • TCP: To perform TCP health checks, ALB sends SYN packets to the backend server to check whether the port of the backend server is available to receive requests.
    • gRPC: To perform gRPC health checks, ALB sends POST or GET requests to the backend server to check whether the backend server is healthy.
    Health Check Method Specify a health check method. Valid values:
    • HEAD: HTTP health checks use the HEAD method by default. Make sure that your backend servers support HEAD requests. If your backend server does 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: gRPC health checks use the POST method by default. Make sure that your backend servers support POST requests. If your backend server does 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. However, the results of the health check are not affected.
    Note This parameter takes effect only when HTTP or gRPC is specified as the health check protocol.
    Protocol Select an HTTP version. Valid values: HTTP1.0 and HTTP1.1.
    Note This parameter takes effect only when HTTP is specified as the health check protocol.
    Port Specify the port that ALB uses when performing health checks on backend servers. Valid values:
    • Backend Server Port: ALB uses the ports of backend servers when performing health checks. This is the default value.
    • Custom Port: ALB uses a specified port when performing health checks. Valid values: 1 to 65535.
    Path Enter the URL path 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 URL 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 (.).
    Normal Status Codes Select one or more HTTP status codes. The specified HTTP status codes are used to determine whether the backend server passes the health check.
    • When the health check protocol is set to HTTP, valid values are http_2xx (default), http_3xx, http_4xx, and http_5xx.
    • When the health check protocol is set to gRPC, valid values are from 0 to 99. Value ranges are supported. You can enter 20 value ranges at most and must separate each range with a comma (,).
    Note This parameter takes effect only when HTTP or gRPC 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 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 Configuration as Template You can select the check box to save the health check configuration as a template. If you select this option, you must enter a name for the template.
    Note This parameter takes effect only when the Select and Load Health Check parameter is set 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. In this example, Instance is selected from the Server Group Type drop-down list.

  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 created 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, specify the type of backend servers, select the backend server that you want to add, and then click Next.
  6. Specify the port and weight of the backend server that you want to add 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 weight of a server and then move the pointer over the Batch operation icon to apply the change to other servers:
    • If you click Replicate to Below, the weights of all the 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 the 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 the 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 the servers in the server group are reset to the default value.
    Notice If you set the weight of a server to 0, the server does not receive requests.

Delete a server group

You can delete a server group when you no longer need it. After you delete a server group, the ECS instances in the server group are retained. If you no longer need the ECS instances that served as backend servers, you can disable or release the ECS 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 delete and choose More > Delete in the Actions column.
  4. In the message that appears, click OK.

References