Alibaba Cloud Application Load Balancer (ALB) supports HTTP, HTTPS, and Quick UDP Internet Connections (QUIC) and is intended for balancing the loads of applications at Layer 7. This topic describes how to create an ALB instance to forward requests from clients to backend servers.

Procedure

1
  1. Prerequisites
    Before you use the ALB service, you must select a region where you want to deploy an ALB instance, and create a virtual private cloud (VPC) and one or more Elastic Compute Service (ECS) instances.
  2. Step 1: Create an ALB instance
    Create an ALB instance. An ALB instance is an entity that provides load balancing services.
  3. Step 2: Create a server group
    Create a server group and add one or more backend servers to receive requests forwarded by ALB.
  4. Step 3: Configure a listener
    Configure a listener to check connection requests and forward the requests to backend servers based on a specified scheduling algorithm.
  5. Step 4: Optional. Configure a CNAME record
    ALB allows you to map your frequently used domain names to the domain name of the ALB instance by using CNAME records. This allows you to access cloud resources in a convenient way.

Prerequisites

Before you use the ALB service, you must select a region where you want to deploy an ALB instance, and create a VPC and one or more ECS instances.

  • Select a region to deploy an ALB instance. Make sure that the ALB instance and the ECS instances that you want to add to the ALB instance are deployed in the same region. In addition, the ALB instance and the ECS instances must be deployed in the same VPC. We recommend that you deploy ECS instances across zones to improve service availability.
  • Create a VPC
  • Create an instance by using the wizard

Step 1: Create an ALB instance

  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 following parameters.
    Parameter Description
    Region Select the region where you want to deploy the ALB instance. Make sure that the ALB instance and Elastic Compute Service (ECS) instances that serve as backend servers are deployed in the same region.
    Network Type Select a network type for the ALB instance. The system allocates a public or private IP address to the ALB instance based on the network type that you select.
    • Internal: If you create an internal-facing ALB instance, a private IP address is allocated. In this case, you can access the ALB instance over only private networks.
    • Internet: If you create an Internet-facing ALB instance, a public IP address is allocated. In this case, you can access the ALB instance over the Internet. Internet-facing ALB provides services to the Internet through elastic IP addresses (EIPs). If you create an Internet-facing ALB instance, you are charged for EIPs, bandwidth resources, and data transfer.
      • If you select Automatically assign EIP, the system automatically creates a pay-as-you-go EIP and associates it with the ALB instance.
      • Alternatively, you can associate an existing EIP with the ALB instance.
        Notice You cannot associate the following EIPs with an ALB instance.
        • Subscription EIPs.
        • Pay-as-you-go EIPs that use the pay-by-bandwidth metering method.
        • EIPs that are associated with other EIP bandwidth plans.
    VPC Select the VPC where you want to deploy the ALB instance. Make sure that the ALB instance and ECS instances that serve as backend servers are deployed in the same VPC.
    Zone
    1. Select two or more zones.
    2. Select a vSwitch and an EIP for each zone.
      • If no vSwitch is available in the zone, create one as prompted.
      • If no EIP is available in the zone, you can keep the default setting Automatically assign EIP. The system automatically creates an EIP and associates it with the ALB instance.
    IP Mode Select an IP mode for the ALB instance.
    • Static IP: Only one IP address is available in each zone. The IP address cannot be changed. If you select Static IP, the ALB instance supports at most 100,000 queries per second (QPS).
    • Dynamic IP: One or more IP addresses are available in each zone. The number of IP addresses that the ALB instance uses automatically increases along with your workloads. In this mode, the ALB instance is highly scalable.
    Edition Select an edition for the ALB instance.
    • Basic: Basic ALB instances support basic routing features such as forwarding requests based on domain names, URLs, and HTTP headers.
    • Standard: Standard ALB instances support advanced routing features in addition to the features of Basic ALB instances. Standard ALB instances support custom TLS security policies, redirection, and rewriting.

    For more information about the differences between Basic and Standard ALB instances, see Features and limits of different editions.

    Associate with EIP Bandwidth Plan Select whether to associate the ALB instance with an EIP bandwidth plan. If you select Associate with EIP Bandwidth Plan, you must select an EIP bandwidth plan. If no EIP bandwidth plan is available, click Purchase EIP Bandwidth Plan and purchase an EIP bandwidth plan. Then, return to the ALB buy page and click Refresh to select the EIP bandwidth plan that you purchased.
    Note You can associate an ALB instance with only a pay-as-you-go EIP bandwidth plan.
    Billing Method Pay-By-Data-Transfer (default): The maximum bandwidth value is not a guaranteed value and is only for reference. In scenarios where demands exceed resource supplies, the maximum bandwidth may be lower than the specified value.
    Note This parameter is available only when Network Type is set to Internet and Associate with EIP Bandwidth Plan is not selected.
    Instance Name Enter a name for the instance.
    Resource Group Select the resource group to which the ALB instance belongs.
  4. Click Buy Now and complete the payment.
  5. Return to the Instances page and select the region where the ALB instance is deployed to view the ALB instance.
    The ALB instance is created

Step 2: Create a server group

  1. In the left-side navigation pane, choose ALB > Server Groups.
  2. On the Server Groups page, click Create Server Group.
  3. In the Create Server Group dialog box, set the following parameters and click Create.
    Parameter Description
    Server Group Name Enter a name for the server group.
    VPC Select a VPC from the drop-down list. The VPC must be the one where the ECS instances that you want to specify as backend servers are deployed.
    Backend Server Protocol Select a backend protocol. In this example, HTTP is selected.
    Scheduling Algorithm Select a scheduling algorithm. In this example, Weighted Round Robin is selected.
    Resource Group Select a resource group from the drop-down list.
    Session Persistence After session persistence is enabled, ALB forwards all requests from a client to the same backend server. In this example, session persistence is disabled.
    Configure Health Check In this example, health checks are enabled. The default health check settings are used.
  4. In the Server group created. dialog box, click Add Backend Server.
  5. On the Backend Servers tab, click Add Backend Server.
  6. In the Add Backend Server panel, select the ECS instances that you want to add and click Next.
  7. Specify the ports and weights of the backend servers and click OK.
  8. Return to the Server Groups page to view the newly created sever group.
    Server groups

Step 3: Configure a listener

  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 listening port that is used to receive and forward requests to backend servers. Valid values: 1 to 65535. 80 is used in this example.
    • Listener Name: Enter a name for the listener.
    • Advanced: In this example, the default advanced settings are used. You can click Modify to modify the settings. For more information about the parameters, see Add an HTTP listener.
    • WAF Protection: You can enable Web Application Firewall (WAF) for the listener. After you select this option, click Enable in the Activate WAF message.
  4. On the Select Server Group wizard page, select the server group to receive requests forwarded by ALB. Click Next.
  5. On the Confirm wizard page, confirm the configurations and click Submit.
  6. On the Listener tab, you can view the listener that you configured.
    You can create forwarding rules for the ALB instance to control how ALB forwards requests to backend servers. For more information, see Configure forwarding rules.

Step 4: Optional. Configure a CNAME record

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

  1. In the left-side navigation pane, choose ALB > Instances.
  2. On the Instances page, copy the domain name of the ALB instance.
  3. 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.
  4. Check whether the CNAME record has taken effect.
    Enter the custom domain name in your browser. If you can access the application, it indicates that the CNAME record has taken effect. For more information, see Verify a DNS record.

Release an ALB instance

After you release an ALB instance, you are no longer charged for the ALB. However, you are still charged for the backend servers.

Note You must disable Deletion Protection before you can delete an ALB instance. Otherwise, the system reports an error.
  1. In the left-side navigation pane, choose ALB > Instances.
  2. Find the ALB instance that you want to delete and choose More > Release in the Actions column.
  3. In the Release Instance message, click OK.

References