Alibaba Cloud Application Load Balancer (ALB) supports HTTP, HTTPS, and QUIC protocols to provide superior processing capabilities for Layer 7 services. This topic describes how to create an ALB instance and forward requests from clients to backend servers.

Overview

This topic includes the following operations:

  1. Prerequisites
    Before you deploy ALB services, plan the region where you want to create an ALB instance, a virtual private cloud (VPC), and an Elastic Compute Service (ECS) instance.
  2. Step 1: Create an ALB instance
    An instance is an entity that runs services. Create an ALB instance first.
  3. Step 2: Create a backend server group
    Create a server group and add a backend server to receive client requests that are forwarded by ALB .
  4. Step 3: Configure a listener
    Configure a listener for the ALB instance, check connection requests, and then forward client requests to the backend server by using forwarding policies that are based on scheduling algorithms.
  5. Step 4: Optional. Configure domain name mapping
    ALB allows you to map your frequently used domain names to the domain name of the ALB instance by using CNAME records. This way, you can access network resources in a more convenient way.

Prerequisites

The region where you want to create the ALB instance, VPC, and ECS instance is determined.

  • The region where you want to create the ALB instance is determined.

    To reduce latency and increase the download speed, we recommend that you select a region that is closest to your customers.

  • A VPC is created.

    A VPC is created in the planned region, and the ALB instance and the backend server group are associated with the VPC. For more information about how to create a VPC, see Work with VPCs.

  • An ECS instance is created.

    Make sure that the ECS instance and the ALB instance are deployed in the same region. In addition, make sure that the ALB instance and the ECS instance belong to the same VPC. We recommend that you deploy the ECS instance in a different zone to improve the availability. For more information about how to create an ECS instance, see Create an instance by using the wizard.

Step 1: Create an ALB instance

An instance is an entity that runs services. Create an ALB instance first.

  1. Log on to the ALB console.
  2. On the Instances page, click Create ALB Instance.
  3. On the ALB (Pay-As-You-Go) International Site buy page, set the parameters.
    Example of the ALB instance configurations:
    • Region: Select the region where you want to create the ALB instance. Make sure that the ALB instance and ECS instance are deployed in the same region. China (Hangzhou) is selected in this example.
    • VPC: Select the VPC to which the ALB instance belongs. Make sure that the ALB instance and ECS instance belong to the same VPC.
    • Zone: Select the zone and vSwitch. If no vSwitch exists in the selected zone, create one by following the console instructions.

    For more information about the parameters, see Create an ALB instance.

  4. Click Buy Now, and activate the ALB instance.
  5. Return to the Instances page, and select the region to view the ALB instance that you created.
    The ALB instance is created

Step 2: Create a backend server group

You must create a backend server group and add a backend server to receive client requests that are forwarded by ALB .

  1. In the left-side navigation pane, choose ALB > Server Groups.
  2. On the Server Groups page, click Create Server Group.
  3. Set the following parameters and click Create.
    • VPC: Select the VPC to which the ALB instance belongs.
    • Configure Health Check: Enable or disable health checks. Health checks are enabled in this example.

      You can click Modify next to Advanced Settings to set more parameters.

    For more information about the parameters, see Manage server groups.

  4. On the Server Groups page, find the server group that you created and click Modify Backend Server in the Actions column.
  5. On the Backend Servers tab, click Add Backend Server.
  6. In the Add Backend Server panel, select the ECS instance that you created and click Next.
  7. Set a port number and weight for the ECS instance, and click OK.
  8. On the Server Groups page, you can view the server group that you created.

Step 3: Configure a listener

Configure a listener for the ALB instance, check connection requests, and then forward client requests to the backend server by using forwarding policies that are based on scheduling algorithms.

  1. In the left-side navigation pane, choose ALB > Instances.
  2. On the Instances page, find the ALB instance that you want to manage and click Create Listener in the Actions column.
  3. On the Configure Listener wizard page, set the following parameters and click Next.
    • Select Listener Protocol: Select a protocol for the listener. HTTP is selected in this example.
    • Listening Port: The listener port used to receive and forward client requests to the backend server. Valid values: 1 to 65535. 80 is used in this example.
    • Listener Name: Enter a name for the listener.
    • Advanced: Click Modify or ignore this parameter.

    For more information about the parameters, see Add an HTTP listener.

  4. In the Select Server Group wizard, select the backend server group to process requests that are forwarded by the ALB instance. Click Next.
  5. On the Confirm page, confirm the configurations and click Submit.
  6. On the Listener tab, you can view the listener that you configured.

    You can set custom forwarding rules for the ALB instance. The forwarding rules specify how the ALB instance forwards requests to the backend server. For more information, see Manage forwarding rules for a listener.

    After you complete the preceding steps, you can access the backend service by using the domain name of the ALB instance. You can map your frequently used domain names to the domain name of the ALB instance by performing Step 4: Optional. Configure domain name mapping.

Step 4: Optional. Configure domain name mapping

ALB allows you to map your frequently used domain names to the domain name of the ALB instance by using CNAME records. This way, you can access network resources in a more convenient way. For more information, see Configure a CNAME record.

  1. On the Instances page, copy the DNS name of the ALB instance.
  2. To create a CNAME record, perform the following operations:
    1. Log on to the Alibaba Cloud DNS console.
    2. On the Manage DNS page, click Add Domain Name.
    3. In the Add Domain Name dialog box, enter the domain name of your host and click OK.
      Notice Before you create the CNAME record, you must use a TXT record to verify the ownership of the domain name.
    4. In the Actions column of the domain name that you want to manage, click Configure.
    5. On the DNS Settings page, click Add Record.
    6. In the Add Record panel, set the following parameters and click Confirm.
      Parameter Description
      Type Select CNAME from the drop-down list.
      Host Enter the prefix of your domain name.
      ISP Line Select Default.
      Value Enter the CNAME. The CNAME is the domain name of the ALB instance that you copied in Step 3.
      TTL TTL: Time-to-live (TTL) limits the lifetime of the record on a server. In this example, the default value is used.
      Note
      • Newly created CNAME records immediately take effect. The time that is required for a modified CNAME record to take effect is limited by the TTL. The default value of TTL is 10 minutes.
      • If the CNAME record that you want to create conflicts with an existing record, we recommend that you specify another domain name.
  3. Check whether the CNAME record takes effect.
    Run the ping or dig command to ping or dig the custom domain name. If the DNS name of the ALB instance is returned, the CNAME record takes effect.

Next step: Release the ALB instance

You can release the ALB instance to save costs. After you release the ALB instance, you are no longer charged for the ALB instance.

  1. In the left-side navigation pane, choose ALB > Instances.
  2. Find the ALB instance that you want to release, and choose The Hide/Show icon > Release in the Actions column.
  3. In the Release Instance message, click OK.