Use Classic Load Balancer (CLB) to distribute traffic across multiple backend servers, eliminating single points of failure and building a highly available application architecture.
Overview
Set up CLB load balancing for IPv4 services in three steps:
-
Create an internet-facing CLB instance: Internet-facing instances include a static public IP address, so no EIP is required.
-
Configure a listener and a server group for the CLB instance:
-
A server group is a set of backend servers that process requests from CLB. Adjust server count dynamically to match traffic.
-
A listener receives client requests on a specific protocol and port, then forwards them to a server group.
-
-
Configure DNS resolution: Map a custom domain name to the CLB service IP address so users access your service through the domain.
Service architecture:
Prerequisites
-
Two ECS instances (ECS01 and ECS02) are created in the same region as the CLB instance. For zonal high availability, place them in different zones.
-
Domain name registration is complete. If the domain points to an Alibaba Cloud server in the Chinese mainland, an ICP filing is also required.
Procedure
Step 1: Create an internet-facing CLB instance
-
Log on to the Classic Load Balancer (CLB) console. In the top navigation bar, select the region for the instance.
-
Click Create CLB. On the buy page, select the region and zone for the CLB instance and specify an instance name.
-
Complete the purchase to create the instance. The new instance is displayed in the Classic Load Balancer (CLB) console.
Step 2: Configure a listener and a server group
-
On the Instances page, find the target instance and click Configure Listener in the Actions column.
-
Configure the listener protocol and listener port.
-
Configure a server group. On the Server Group tab, click Create Server Group, enter a name such as
server-group-test, and click Add.Select the backend servers for the CLB instance.
For Backend server type, select ECS/ENI, select the target ECS instances, and then click Next.
Configure backend server ports and add the servers.
Set port to
80, use the default weight of100, and then click Add. -
Keep the default health check settings.
The default health check settings are as follows: The protocol is HTTP and the method is HEAD. The health check port is the backend server port, and the path is
/. The response timeout is 5 seconds, the interval is 2 seconds, and the healthy and unhealthy thresholds are both 3. The healthy status codes are http_2xx and http_3xx. -
Submit the configuration. A Configuration succeeded dialog confirms that the Server Group, Layer-7 Load Balancing, and Start Listener steps completed. Click Got it.
Step 3: Configure DNS resolution
-
On the Instances page, find the target instance and copy the IP address from the IP Address column.
-
Add an A record to map your domain name to the CLB service IP address.
-
Log on to the Alibaba Cloud DNS console, find the target domain name, and click Settings in the Actions column.
-
Click Add Record. Configure the following parameters. Keep defaults for other parameters.
-
Record Type: Select A to map the domain name to an IPv4 address.
-
Hostname: The prefix of the domain name.
-
Record Value: The service IP address of the CLB instance.
-
-
Verify the results
From any internet-connected client:
Enter the domain name in a browser and refresh multiple times. Requests alternate between ECS01 and ECS02.
If the listener uses a non-default port, include it in the URL. Example: http://www.example.com:9000.
Stop one ECS instance. Requests continue to be processed, confirming CLB failover.
More operations
Clean up resources
Delete unused resources to avoid unnecessary charges.
-
Delete the DNS record: Log on to the Alibaba Cloud DNS console and click the target domain name. Find the target DNS record and click Delete in the Actions column.
-
Delete the CLB instance: Log on to the Classic Load Balancer (CLB) console. In the Actions column of the target instance, choose
> Release Settings, and then release the instance immediately. -
Delete the ECS instances, security group, and other resources:
-
Log on to the Elastic Compute Service (ECS) console. In the top navigation bar, select the region where the instances are deployed. Find the target instance, click
in the Actions column, select Release in the pop-up window, and then release the instance immediately. -
Log on to the Security Groups page of the ECS console. In the top navigation bar, select the region where the security group is deployed, find the target security group, and click Delete in the Actions column.
-
-
Delete the VPC and related resources: Log on to the Virtual Private Cloud (VPC) console. In the top navigation bar, select the region where the instance is deployed. Click Delete in the Actions column of the VPC instance to delete the VPC, vSwitches, and other network resources.
FAQ
Internet-facing vs. intranet-facing instances
A newly created intranet-facing CLB instance is deployed in a VPC.
|
Feature |
Internet-facing CLB instance |
Intranet-facing CLB instance |
|
Internet accessibility |
An internet-facing CLB instance has a static public IP address bound to the instance. When releasing the instance, convert its public IP to an elastic IP address (EIP) to retain it. |
An intranet-facing CLB instance has no internet access by default. Associate an elastic IP address (EIP) with an intranet-facing CLB instance to enable internet access. The EIP can be associated or disassociated at any time. |
|
Service address |
Provides only a public IP address. |
Provides a private IP address within a VPC. If an EIP is associated, the instance also provides the public IP address of the EIP. |
|
Network capability |
You can add backend servers, such as ECS instances and elastic network interfaces (ENIs), from different VPCs. |
You can add backend servers, such as ECS instances and ENIs, only from the same VPC. |
After an instance is created, you cannot change its network type from internet-facing to intranet-facing or vice versa.
Choosing billing methods
|
Billing method |
Instance metering method |
Instance network type |
Internet data transfer metering method |
Use cases |
|
Pay-by-LCU |
Internet-facing |
Pay-by-data-transfer |
|
|
|
Internal |
N/A |
|||
|
Pay-by-specification (sale discontinued) |
Internet-facing |
Pay-by-data-transfer |
|
|
|
Pay-by-bandwidth |
||||
|
Internal |
N/A |
Pay-by-specification instance specifications
Pay-by-specification CLB instances are no longer available for purchase since June 1, 2025, 00:00:00 (UTC+8). For more information, see End of sale for pay-by-specification CLB instances.
Key performance metrics: maximum connections, connections per second (CPS), and queries per second (QPS). Instance specifications.
Does pay-by-bandwidth limit bandwidth?
Yes.
For example, a 20 Mbit/s pay-by-bandwidth instance limits both inbound and outbound traffic to 20 Mbit/s.
Can I migrate a CLB instance to another VPC?
No.
Create a new CLB instance in the target VPC instead.
Can CLB forward traffic to non-Alibaba Cloud servers?
No. CLB supports only Alibaba Cloud ECS instances, ENIs, and ECI instances as backend servers.
Can I use cross-account ECS instances as backend servers?
No. Backend servers must belong to your own Alibaba Cloud account.
Can I associate an EIP with multiple resources?
No. Each EIP can be associated with only one resource at a time.