Before you can use the ALB service, you must create a server group and add one or more backend servers to the server group. 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 Configure forwarding rules.

Create a 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, click Create Server Group.
  4. Set the parameters that are described in the following table and click Create.
    Parameter Description
    Server Group Type Select a server group type:
    • Instance: allows you to add backend servers by specifying the names or IDs of ECS instances.
    • IP: allows you to add backend servers by specifying the IP addresses of ECS instances.
    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 VPC from the VPC drop-down list. Only servers in the VPC can be added to the server group.
    Backend Server Protocol Select a backend protocol. Valid values:
    • HTTP: This is the default value. 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.
    • GRPC: If you select this option, you can associate the backend servers with HTTPS and QUIC listeners.
    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 combination of the weights and number of connections to backend servers. If two backend servers have the same weight, the backend server with fewer connections is more likely to be scheduled and receives more requests.
    • Source IP Consistent Hashing: Requests from the same source IP address are distributed to the same backend server.
    Resource Group Select the resource group to which the server group belongs.
    Session Persistence Specify whether to enable or disable session persistence. If session persistence is enabled, ALB forwards all requests from a client to the same backend server.
    • Cookie Persistence: Select a method to handle cookies.
      • 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, ALB 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 ALB distributes the request to the recorded backend server.
    • Session Persistence Timeout Period: Specify the timeout period of session persistence. Valid values: 1 to 86400. Unit: seconds.
    Configure Health Check Specify whether to enable or disable 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 When you create a health check, you do not need to specify a server group or listener. You can associate the health check with a server group or listener after the health check is created.
    Protocol Select the protocol of the health check. Valid values:
    • HTTP: To perform HTTP health checks, ALB sends HEAD or GET requests to a backend server to check whether the backend server is healthy.
    • TCP: To perform TCP health checks, ALB sends SYN packets to a 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 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 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: By default, gRPC health checks use the POST method. 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 length of a response exceeds 8 KB, the response is truncated. However, the health check result is 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 the health check protocol is set to HTTP.
    Port Specify the ports that are probed by the health check.
    • Backend Server Port: Health checks probe the ports of backend servers. This is the default setting.
    • Custom Port: Health checks probe a specified port. 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, hyphens (-), forward slashes (/), periods (.), percent signs (%), question marks (?), number signs (#), and ampersands (&). The URL can also contain the following extended 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: uses the private IP addresses of backend servers as the domain names 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 indicate that health checks are normal.
    • 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. You can enter at most 20 value ranges and separate them with commas (,).
    Note This parameter takes effect only when HTTP or GRPC is specified as the health check protocol.
    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 time 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. 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 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, specify the type of backend server, 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 operations icon to change the weights of other servers:
    • 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.

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 backend servers in the server group are not affected. If you no longer need an ECS instance that serves as a backend server, you can stop or release the ECS 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 More > Delete in the Actions column.
  4. Click OK.