×
Community Blog Quick Guide to Load Balancing on Alibaba Cloud

Quick Guide to Load Balancing on Alibaba Cloud

In this article, we look at how we can quickly set up load balancing on Alibaba Cloud for our websites and applications with Server Load Balancer.

By Sai Sarath Chandra, Alibaba Cloud Tech Share Author. Tech Share is Alibaba Cloud's incentive program to encourage the sharing of technical knowledge and best practices within the cloud community.

This article is intended for sharing my experience of what I have learned about Alibaba Cloud Server Load Balancer (SLB) from Alibaba Cloud Academy. Although this is not a new topic to me, I took the ACA course to get my fundamentals right as I believe it is very important. I've also learned a lot of new things, especially topics related to Alibaba Cloud-specific technologies. I gained a deeper understanding on how Alibaba Cloud can help my organization increase its profit by reducing the operating costs.

If you are not familiar with load balancing and scaling, you should browse for free e-learning classes on this subject, and try the Alibaba Cloud Apsara Cloud Certifications to consolidate your knowledge.

What Is Load Balancer?

Load balancing might seem like a simple concept initially, but this works in conjunction with multiple other services/products, which gives us an opportunity to discuss about some other products.

There are several definitions out there but I would like to explain it in my own terms, it's obvious that primary task is to balance the load (incoming requests between application/servers). To achieve this there are multiple algorithms/methods like Round Robin and Weighted Round Robin.

Based on the OSI model, the level where load balancing is happening varies as described below:

  1. Layer 4 Load Balancing - The ability to direct traffic based on data from network and transport layer protocols, such as IP address and TCP port.
  2. Layer 7 Load Balancing - The ability to make routing decisions based on application layer data and attributes.

There is also a relatively newer concept in load balancing called Global Server Load Balancing. This method handles the traffic distribution between multiple servers across multiple regions.

I would like to explain my understanding with an example

1

Think of the above situation where there are 3 clients that want to access your application, but our backend server can take the load of only one Client/Server. In this scenario we have 3 servers named Server 1, Server 2 & Server 3.

Problem: Since all the servers are exposed via different IP's say IP1, IP2 & IP3.

  1. How will Client know which IP to choose?
  2. What happens when the service is down with the server associated to the user?
  3. How we can we monitor all the IP's?

Solution:

2

Here we have the Server Load Balancer (SLB) to the rescue. From server side, we have all the IP's mapped to the Server Load Balancer and one public IP exposed. While configuring, we have the option of choosing how we want to distribute the requests to the server. In our scenario, since all the Servers takes the same load, we go with the 'Round Robin' algorithm. This shares all the requests equally.

All clients can now access the Servers over the SLB, preventing the issue of letting each user know what the IP of the SLB is. Also, we can monitor and provide additional security using the SLB IP, which is easier compared to the previous case of 3 IP's

With Alibaba Cloud SLB, this means we have multiple other features available:

  1. You will be charged only for the public traffic. If your SLB is used within the private network, you get this service for free.
  2. You can put up Auto Scaling, which is another awesome feature, where the SLB monitors the traffic and using some configurations. It creates the Instances for you and handle the load. This reduces the manual work you need to do when in case of need.
  3. You will also get the monitoring facility right in the console. Thanks to SLB listeners and the Alibaba Cloud Team which gives a quick view of what is happening.

OK, enough talk. It's time for a real demonstration.

Concept

There are 3 components you need to start with SLB

  1. Server Load Balancer Instance: A Server Load Balancer instance is a running entity of the Server Load Balancer service. To use Server Load Balancer, you must first create a Server Load Balancer instance.
  2. Listener: A listener defines how incoming requests are distributed. An SLB instance must contain at least one listener.
  3. Backend Server: The Elastic Compute Service (ECS) instances that are added to an SLB instance to respond to the distributed requests.

Demonstration

Login to the Alibaba Cloud Console & Navigate to the ECS Console.

3

To keep the context of the article I am not going through the creation of ECS instance. You can see that I have two instances named "SLB_BS_1" & "SLB_BS_2" in "Kuala Lumpur" Region.

We will navigate to the SLB Console provided using the quick link provided in the left-hand side menu.

SLB Instance Creation

If you are someone like me who haven't created SLB. You will see something familiar to this.

4

Click on the "Create SLB Instance." You will be redirected to the SLB Console.

5

If you see there is a minimal configuration during the SLB Creation, options are obvious.

Instance Type: If you choose "Internet" (which is public SLB) you will get charged and If you choose "Intranet" (Private SLB).

Instance Spec: For demonstration purpose I chose the Shared-Performance Instance. Unless prototyping, this "Instance Spec" is not recommended.

Click "Buy Now". Then you console should show something similar to this.

6

Configure SLB

If you click on the SLB's Name, you will see there are no listeners. Click on "Add Listener".

7

There are 4 steps while creating listener in Alibaba Console.

  1. Protocol & Listener
  2. Backend Servers
  3. Health Check
  4. Submit

Protocol and Listener

Here you will select the protocol of your SLB, this decides whether you will be configuring the Layer-4 or Layer-7.

Listening Port

This will be the listening port to your SLB, the incoming traffic to the SLB. To make things simple I kept the same port as in my http web server on ECS Instances. I will leave the rest of the settings to default.

8

Backend Server

This is where you will associate the ECS instances to the SLB, click on "Add". Under the "Servers Added" section.

9

Post this you will see a small window slides in with the ECS instances information in that SLB instance region. Click the instances to add

10

I will keep the "Enable health check" option checked as it gives the summarized information about my ECS Instances.

11

Click "Next" you will move the "Submit" Screen where all the configuration is checked and you will see success against all the items. Click "Ok."

12

That's it!! Congratulations, you have configured your first SLB. If you hit the SLB IP, then you should see the Webpage is served from one of the two ECS instances

13

When I hit for the first time it shows "This is from ECS Instance 02"

14

When I hit the same URI Again it shows "This is from ECS Instance 01"

15

Summary

I hope this brief tutorial helped understand the concepts and the steps involved in using Server Load Balancer (SLB) on Alibaba Cloud. To summarize,

  1. You can put SLB on the same PORT of two ECS Instances.
  2. SLB opens up to Auto Scaling through which we can reduce the manual effort of provision/deletion instances during peak/off-peak time.
  3. Alibaba Cloud SLB enables this with the basic protection which in great for organizations which are just starting off on cloud, that too without any configuration.

If you want to learn more about Alibaba Cloud or cloud computing in general, I recommend visiting the Alibaba Cloud Academy, and try the Alibaba Cloud Apsara Cloud Certifications to consolidate your knowledge.

2 2 1
Share on

Alibaba Clouder

2,599 posts | 762 followers

You may also like

Comments

5039836173598356 September 5, 2018 at 6:58 pm

Fantastic post boss.I think I'm your big fan and I really appreciate your effort, thanks for sharing information great job... Keep PostingSee YouTcHttp://sattafixjodi.com

5039836173598356 September 5, 2018 at 6:58 pm

Sattafixjodi.com