This topic describes the preparations that you must complete before you use the Classic Load Balancer (CLB) service. For example, you must determine the type of listener that your business requires and the type of network to deploy a CLB instance before you use the CLB service.

Select a region to deploy a CLB instance

When you select a region, take note of the following items:

  • By default, you cannot deploy a CLB instance across multiple regions. Make sure that the CLB instance and the Elastic Compute Service (ECS) instances that you want to add to the CLB instance belong to the same region.

    For example, if the ECS instance that hosts your services is deployed in the China (Hangzhou) region, you must create a CLB instance in the China (Hangzhou) region. This way, you can add the ECS instance to the CLB instance.

  • CLB supports primary/secondary zone deployment in most regions. You can deploy a CLB instance across zones to achieve disaster recovery across data centers in the same region. This ensures service stability and reliability. We recommend that you select a region that supports primary/secondary zone deployment.

Select the type of network to deploy your CLB instance

CLB provides load balancing services over the Internet and the internal network.

  • If you want to use CLB to distribute requests from the Internet, create an Internet-facing CLB instance.

    An Internet-facing CLB instance is assigned a public IP address to receive requests from the Internet.

  • If you want to use CLB to distribute requests from the internal network, create an internal-facing CLB instance.

    An internal-facing CLB instance uses a private IP address from the IP address pool of Alibaba Cloud to distribute requests within the internal network of Alibaba Cloud. An internal-facing CLB instance cannot distribute requests over the Internet.

Select a specification for your CLB instance

  • If your workloads expect only minor fluctuations, we recommend that you select Pay-By-Specification. You are charged a specification fee on an hourly basis.
  • If your workloads expect periodic or large fluctuations, we recommend that you select Pay-By-LCU. Pay-by-LCU CLB instances can automatically scale resources on demand. In addition, you do not need to specify a specification. You are charged for consumed LCUs on an hourly basis.

Select a listening protocol

CLB supports Layer 4 load balancing over TCP and UDP and Layer 7 load balancing over HTTP and HTTPS.

  • Layer 4 listeners forward requests directly to backend servers. When a CLB instance receives a request, the CLB instance modifies the destination IP address and destination port of the data packet based on the listener port. Then, the CLB instance forwards the request to a backend server. A TCP connection is established between the client and the backend server.
  • A Layer 7 listener functions as a reverse proxy. After a client request reaches a Layer 7 listener of CLB, CLB establishes a new TCP connection to a backend server over HTTP, instead of directly forwarding the request to the backend server.

    Compared with Layer 4 listeners, Layer 7 listeners require an additional step of Tengine processing. The throughput capacity of Layer 7 listeners may be limited by factors such as client port exhaustion or excessive workloads on backend servers. If your business requires higher performance, we recommend that you use Layer 4 listeners.

    For more information, see Protocols.

Create backend servers

Before you use the CLB service, you must create ECS instances, deploy applications on the ECS instances, and then add the ECS instances to your CLB instance to process client requests.

When you create ECS instances, take note of the following items:
  • Make sure that the ECS instances and the CLB instance are deployed in the same region. In addition, make sure that the CLB instance and the ECS instances belong to the same virtual private cloud (VPC). We recommend that you deploy the ECS instances across multiple zones to improve service availability. For more information about how to create an ECS instance, see Create an instance by using the wizard.

    In this example, an ECS instance named ECS01 and an ECS instance named ECS02 are created in the China (Hangzhou) region.

  • You must deploy your applications on the ECS instances.
    In this example, two static web pages are hosted on ECS01 and ECS02 by using Apache.
    • Enter the elastic IP address (EIP) that is associated with ECS01 in the address bar of your browser. ECS01
    • Enter the EIP that is associated with ECS02 in the address bar of your browser. ECS02
    No additional configurations are required after you deploy applications on the ECS instances. However, if you want to configure a Layer 4 listener (TCP or UDP) and the ECS instances use Linux, perform the following steps:
    1. Log on to the ECS instance and run the grep rp_filter /etc/sysctl.conf command. Make sure that the values of the following parameters in the /etc/sysctl.conf configuration file are set to 0:
      net.ipv4.conf.default.rp_filter = 0
      net.ipv4.conf.all.rp_filter = 0
    2. Add a file to the /etc/sysctl.d/ directory. For example, you can add a file named /etc/sysctl.d/90-net-common.conf. Then, add the following parameter to the file based on the port of the ECS instance:
      net.ipv4.conf.eth0.rp_filter = 0
    3. After the file is added, run the sysctl -p command for the configurations to take effect.