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 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 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. In the Create Server Group dialog box, set the following parameters and click Create.
    ParameterDescription
    Server Group TypeSpecify 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 NameEnter a name for the server group.
    VPCSelect a virtual private cloud (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 ProtocolSelect 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 and QUIC listeners.
    Note
    • HTTPS listeners of a basic ALB instance can be associated only with server groups that use HTTP.
    • You can select only HTTP for server groups of the Function Compute type.
    Scheduling AlgorithmSelect 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 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 is expected to receive more requests.
    • Consistent Hash: Requests from the same source IP address are forwarded to the same backend server.
    Note This parameter is unavailable for server groups of the Function Compute type.
    Select a hash factorSelect a hash factor. Default value: Source IP. Valid values:
    • Source IP: Requests from the same source IP address are forwarded to the same backend server.
    • URL Configuration: Requests for the same URL are forwarded to the same backend server.
    Note This parameter takes effect only when you set the Scheduling Algorithm parameter to Consistent Hash.
    Specified URLEnter a URL.
    Note This parameter takes effect only when you set Scheduling Algorithm to Consistent Hash and Hash Factor to URL Configuration.
    Enable IPv6Specify whether to enable IPv6. IPv6 is disabled by default.
    • After 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 IPv6 is disabled, you can add only IPv4 backend servers to the server group. You can set Server Group Type to Server, IP, or Function Compute.
    Note
    • The IPv6 feature is unavailable by default. To use the IPv6 feature, log on to the Quota Center console. On the Privileges page, enter slb_user_visible_gray_label/support_ipv6 in the Quota ID search box and click Apply in the Actions column. For more information, see Manage ALB quotas.
    • If IPv6 is not enabled 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 IPv6 server groups.
    Session PersistenceSpecify whether to enable 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 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 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 cookies.
    • 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.
    Long-lived TCP ConnectionSpecify whether to enable the long-lived TCP connection feature. The feature is disabled by default.

    When this feature is enabled, a specific number of TCP connections are kept alive between ALB and the backend server. When the ALB instance receives a new request and an idle long-lived TCP connection exists, ALB preferentially uses the TCP connection to forward the request to the backend server. This reduces the number of TCP handshakes and the workload on the backend server.

    Note By default, this feature is unavailable. To use this feature, log on to the Quota Center console. On the Privileges page, enter slb_user_visible_gray_label/upstream_keepalive in the Quota ID search box and click Apply in the Actions column. For more information, see Manage ALB quotas.
    Configure Health CheckSpecify whether to enable the health check feature.
    Advanced SettingsAfter you enable the health check feature, you can click Modify to the right of Advanced Settings to configure advanced settings.
    Select and Load Health CheckSelect 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 ProtocolSelect a health check protocol. 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 MethodSpecify a health check method. Valid values:
    • HEAD: HTTP health checks automatically 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: gRPC health checks automatically 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 when you set the Health Check Protocol parameter to HTTP or gRPC.
    • If you set the Health Check Protocol parameter to HTTP, you can set the Health Check Method parameter to HEAD or GET. If you set the Health Check Protocol parameter to gRPC, you can set the Health Check Method parameter to POST or GET.
    Health Check Protocol VersionSelect an HTTP version. Valid values: HTTP1.0 and HTTP1.1.
    Note This parameter takes effect only when you set the Health Check Protocol parameter to HTTP.
    PortSpecify the ports on which you want to perform health checks.
    • 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.
    Health Check PathEnter 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 NameEnter 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 CodesSelect one or more HTTP status codes. The specified HTTP status codes are used to indicate that a backend server passes a health check.
    • If you set the Health Check Protocol parameter to HTTP, the valid values are http_2xx (default), http_3xx, http_4xx, and http_5xx.
    • 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 each range with a comma (,).
    Note This parameter takes effect only when you set the Health Check Protocol parameter to HTTP or gRPC.
    Response Timeout PeriodSpecify the 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 IntervalSpecify the interval between two consecutive health checks.
    Healthy ThresholdSpecify the number of times that an unhealthy backend server must consecutively pass health checks before it is declared healthy.
    Unhealthy ThresholdSpecify 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 this 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 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 Instance type

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. 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, 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.

  6. In the Ports/Weights step, set the port and weight of the server 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 Batch operation icon:
    • 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.
    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, see Specify a function from Function Compute as a backend server of ALB.

  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 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, add a function by using one of the following methods, set the required parameters, and then click OK.
    • Add a function by selecting it
      ParameterDescription
      Configuration ModeSelect a mode for adding a backend server.

      Select Service from the drop-down list.

      ServicesSelect a Function Compute service. If no services are available, you can click Create a service to create a Function Compute service. For more information, see Create a function in the Function Compute console.
      EditionSelect LATEST.

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

      FunctionsSelect 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.
      NoteEnter a description.
    • Add a function by specifying ARN
      ParameterDescription
      Configuration ModeSelect a mode for adding a backend server.

      Select ARN from the drop-down list.

      ARNEnter the ARN of the function that you want to add.

      You can obtain 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.

      NoteEnter 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 have not enabled remote IP address, the added IP address must be within the CIDR block of the current VPC. If you have enabled remote IP address, you can add IP addresses that are not within the current VPC CIDR block. For more information, see Specify an ECS instance in a VPC as a backend server of ALB in a different region and Specify an on-premises server as a backend server of ALB.

Limits on adding backend servers of the IP type across regions:
  • You can add only internal-facing servers and cannot add Internet-facing servers.
  • You cannot add ALB or CLB instances that reside in the same VPC.
  • You can use Enterprise Edition transit routers and Express Connect for cross-region forwarding. Basic Edition transit routers are not supported.
  • Each region in a network that is managed by a Cloud Enterprise Network (CEN) instance can have only one VPC that contains one or more ALB instances to which backend servers are added across regions. Example 1
    • You cannot enable ALB in multiple VPCs in the same region to use the same transit router to access backend services. Example 2
    • You cannot enable ALB in multiple VPCs in the same region to use multiple transit routers to access the same backend service. Example 3
  • Network traffic between an ALB instance and its backend servers can be routed based only 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 created 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 one or more IP addresses and click Next.
    • If the IP address that you entered is within the CIDR blocks of the VPC where the server group belongs, you do not need to turn on Remote IP Address.
    • If the IP address that you entered is not within the CIDR blocks of the VPC where the server group belongs, you need to turn on Remote IP Address.
    Note You can click + Add IP Address to add multiple backend servers.
  6. In the Ports/Weights wizard, set the port and weight of the server 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 Batch operation icon:
    • 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.
    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 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 in the Actions column.
  4. In the Modify health check dialog box, enable or disable health checks, or click Modify next to Advanced Settings to modify the health check settings.
    Warning
    • After health checks are disabled, ALB no longer checks the backend servers. If a backend server fails, 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 for a listener, 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 disable 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 The More icon > Delete in the Actions column.
  4. In the message that appears, click OK.

References