How to distribute traffic across multiple servers using Alibaba Cloud Server Load Balancer?

My name is Ishita Mahajan and I am a Roopu Cloud Ambassador. In this blog post I will deep dive into the Alibaba Cloud Server Load Balancer (SLB).

What is Alibaba Cloud Server Load Balancer?

Alibaba Cloud Server Load Balancer (SLB) automatically distributes incoming application traffic across multiple applications, microservices, and containers hosted on ECS servers to improve the availability and the fault tolerance capability of your applications.

A scenario where SLB plays a vital role in your cloud environment

Suppose you have an e-commerce web application running on your ECS server and having a low number of users at the start. As your business increases the number of requests to your web server your server failure may occur. To avoid this, you have the option to increase the number of instances on which the same application is running on.

But the question comes, how will you transfer the incoming traffic to multiple instances? To overcome this, Alibaba Cloud Server Load balancer (SLB) distributes traffic among multiple instances. The SLB Instance receives the incoming traffic and distributes that traffic to the configured ECS servers. It also provides health checks for the instances. If any instance is unhealthy, then the SLB instance stops sending traffic to that unhealthy instance.

You can also use Multi-Zone Disaster Tolerance in SLB for high availability and fault tolerance. Due to any failure, if a primary zone becomes unavailable, the Server Load Balancer automatically switches to a backup zone to restore its service.

SLB Architecture

The SLB Architecture consists of listeners and instances. Listeners are the front-end to check the connection requests and forward that requests to the backend servers. SLB instances are the important part. Without an SLB instance, SLB service cannot start. To use the Alibaba Cloud SLB service you have to create a Server Load balancer instance with at least two ECS instances configured and one listener. Backend servers are added to SLB to distribute the workload.

According to to the protocols applied on  the application , Alibaba SLB has two parts: Layer 4 SLB and Layer 7 SLB.

Layer 4 SLB

1. Supports TCP and UDP requests
2. Operates at the transport layer
3. Header cannot be modified
4. It uses the customized open-source LVS (Linux Virtual Server)

Layer 7 SLB

1. Supports HTTP and HTTPS requests
2. Operates at the application layer
3. It uses open-source software Tengie
4. Headers may be modified


It’s time for the demo. Let’s login to the Alibaba Cloud console and click on Elastic Compute service.

Alibaba Cloud console

First, create two servers on which the SLB will distribute the traffic.

Alibaba Cloud ECS instances

For this  demo I’ve configured two ECS servers and added different images to them. Each of them with different Alibaba Cloud logos, one in orange and the other in black.

Alibaba Cloud ECS instances output

After the creation of the two ECS servers, go back to the beginning and click on Server Load Balancer as shown in the figure below.

Alibaba Cloud console

To start the SLB service, we need to first create the SLB Instance. Make sure that you create the SLB instance in the region  where the ECS instances are created.

SLB console configuration
SLB console configuration

Once the SLB is created, add the Backend servers into it as shown in the figure below. At least two backend servers must be added to the Server Load Balancer.

SLB server configuration
SLB server configuration

Now, I set the same weight to each backend server.

Setting the weight to backend servers

Now it’s time to add and configure the SLB listener. At least one listener must be added into the Server Load Balancer.

Adding SLB listeners

In the figure below, you can see the configuration for the listener. I selected HTTP protocol, which means it is a Layer 7 SLB . Additionally, I’ve given “my listener” name to the listener.

Configuring the SLB listener

Next, go to Advance Options and select the policy you want. In my case, I selected Weighted Round Robin (WRR).

Weighted Round Robin (WRR) policy

Next is configuring the Default Server group. You can also create the Backend server group with a specific name by using Vserver Group. Here I have not created any group so my backend servers go to the default server group. 

Configuring the default server group

Next, you can enable health checks to your servers. I enable it.

Enabling the health check

After this, click on the submit button, and your SLB will be created as shown in the figure below.

SLB configuration successful

 Now, you have to activate the SLB, by clicking on “Activate Now”.

Activating the SLB

After the creation of the SLB , take the SLB Instance IP and paste it on Google.

The following video is the output of the demo and shows how traffic distribution takes place:

How to distribute traffic across multiple servers using Alibaba Cloud Server Load Balancer

Leave a Comment

Scroll to Top