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.
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.
First, create two servers on which the SLB will distribute the traffic.
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.
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.
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.
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.
Now, I set the same weight to each backend server.
Now it’s time to add and configure the SLB listener. At least one listener must be added into the Server Load Balancer.
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.
Next, go to Advance Options and select the policy you want. In my case, I selected Weighted Round Robin (WRR).
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.
Next, you can enable health checks to your servers. I enable it.
After this, click on the submit button, and your SLB will be created as shown in the figure below.
Now, you have to activate the SLB, by clicking on “Activate Now”.
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: