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

Getting started
  1. Preparations
    Before you use the ALB service, you must select a region to deploy an ALB instance, create a virtual private cloud (VPC), and create Elastic Compute Service (ECS) instances.
  2. Step 1: Create an ALB instance
    To use the ALB service, you must first create an ALB instance. An ALB instance is an entity that provides load balancing services.
  3. Step 2: Create a server group
    You must 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 to listen for connection requests and forward the requests to backend servers based on a specified scheduling algorithm.
  5. Step 4: Optional. Create a CNAME record
    ALB allows you to map your frequently visited domain names to the publicly accessible domain name of the ALB instance by using CNAME records. This facilitates access to network resources.

Preparations

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

  • Choose a region to deploy your 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 different 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.
  3. On the ALB (Pay-As-You-Go) buy page, set the following parameters.
    Parameter Description
    Region Select the region where you want to create the ALB instance.
    Network Type Select the network type of the ALB instance. The system allocates a public or private IP address to the ALB instance based on the selected network type.
    • Internal: If you create an internal-facing ALB instance, a private IP address is allocated. In this case, you can access the ALB instance only over private networks.
    • Public-facing: 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 instances use elastic IP addresses (EIPs) to provide services over the Internet. If you create an Internet-facing ALB instance, you are charged for EIPs, bandwidth resources, and data transfer.
    VPC Select the VPC where you want to deploy the ALB instance.
    Zone
    1. Select two or more zones.
    2. Select a vSwitch in each zone. If no vSwitch is available, create a vSwitch as prompted.
    3. Optional:Select an EIP in each zone that you selected.
      • Use the default setting Automatically assign EIP if no EIP is available in the zone. The system will automatically create a pay-by-data-transfer EIP and associate the EIP with your ALB instance.
      • You can also specify an existing EIP to be associated with the ALB instance.
        Notice You cannot associate the following EIPs with an ALB instance.
        • Subscription EIPs.
        • Pay-by-bandwidth EIPs.
        • EIPs that are associated with EIP bandwidth plans other than the EIP bandwidth plan that is used by 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. An ALB instance that uses a static IP address 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 is based on your workloads. An ALB instance that uses dynamic IP addresses can automatically scale on demand.
    Edition Select an edition for the ALB instance.
    • Basic: Basic ALB instances support basic routing features such as request forwarding 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, redirects, and rewrites.

    For more information about the differences between the two instance editions, see Functions and features.

    Associate with EIP Bandwidth Plan Specify 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 to 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 This parameter is available only if Network Type is set to Internet.
    Billing Method Pay-by-Data-Transfer (default): The maximum bandwidth is not guaranteed and the value is for reference only. In scenarios where demands outstrip resource supplies, the maximum bandwidth may be limited.
    Note This parameter is available only if Network Type is set to Internet and Associate with EIP Bandwidth Plan is not selected.
    Instance Name Enter a name for the ALB instance.
    Resource Group Select the resource group to which the ALB instance belongs.
    Note A service-linked role is required the first time that you create an ALB instance. The service-linked role allows the ALB instance to access cloud services and resources such as elastic network interfaces (ENIs), security groups, EIPs, and EIP bandwidth plans. For more information, see Service-linked roles for ALB.
  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 Type Select a server group type. Valid values:
    • Instance: allows you to specify ECS instances as backend servers.
    • IP: allows you to add backend servers by IP address.
    • Function Compute: allows you to add backend servers by specifying functions from Function Compute.
    In this example, Instance is selected.
    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 the VPC where the ECS instances are deployed from the drop-down list.
    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 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 and 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 one or more ECS instances 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 server group that you configured.
    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:
    • Listener Protocol: Select a protocol for the listener. HTTP is selected in this example.
    • Listener 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 Settings: 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) protection for the listener. After you select this option, click Enable in the Activate WAF message.
  4. On the Select Server Group wizard page, select a server group. The server group is used to receive requests forwarded by ALB. Then, 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 created.
    You can add forwarding rules to the listener of the ALB instance to control how ALB forwards requests to backend servers. For more information, see Manage forwarding rules for a listener.

Step 4: Optional. Create a CNAME record

ALB allows you to map your frequently visited domain names to the publicly accessible domain name of the ALB instance by using CNAME records. This facilitates access to network resources. 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 the domain name of your host.
      ISP Line Select Default.
      Value Enter the CNAME. The CNAME is the domain name of the ALB instance.
      TTL Select the time-to-live (TTL) value of the record on the DNS 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 determined by the TTL value. The default TTL value 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 is valid.
    Enter the custom domain name in your browser. If you can access the application, it indicates that the CNAME record is valid. 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 instance. 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

API references: