Alibaba Server Load Balancer
The course is part of this learning path
This course introduces the Alibaba Server Load Balancer (SLB) service and its features, components, and settings. You'll also learn how to use SLB through a guided demonstration from the Alibaba platform.
- Get a basic understanding of Alibaba Cloud SLB
- Learn about the features, components, and additional settings of SLB
- Learn how to set up a server load balancer
This course is intended for anyone looking to use server load balancer to manage their Alibaba Cloud workloads, as well as anyone studying for the ACP Cloud Computing certification exam.
To get the most out of this course, you should have a basic understanding of the Alibaba Cloud platform.
Let's now try out Server Load Balancer for ourselves from the Alibaba Console. So I'm here on alibabacloud.com. That's our official website. I will go over here to the upper right-hand corner and click on Console to enter the web console. And I've already set up two ECS instances to act as the backend servers behind our server load balancer. So let's go look at those first. So if I click here on Elastic Compute Service, that will take me over to the ECS console. I can navigate to the Singapore region where I have these two servers running, and I'll show you what's happening there.
So I have these two different servers, one called ecs-a, that's in Zone B, and one called ecs-b, which is in Zone C. I've given them public IP addresses for now, so that I can log into them and show you what they're running. You'll see that ECS Instance A is running Apache and has a webpage that simply says ECS Instance A. Same thing for Instance B, if I visit its public IP address, I can see the ECS Instance B page. And I've actually put different pages on each instance so that when we put them behind the load balancer, you can see that the load balancer is in fact distributing requests evenly across these two instances. If they have the same HTML boilerplate code here, then you wouldn't be able to see any difference.
So I've intentionally put slightly different index.html files on each of these two web servers so that you can see that there is in fact a difference between the two of them. So now what we need to do is go set up our server load balancer, configure a listener, and also create what's called a V server group or virtual server group. So let's go do that. So I've closed that ECS tab and we're back at the console homepage. Now, I'll go over to Server Load Balancer here and we'll create a SLB in the Singapore region. So here we are in Singapore, I'll click on Create Instance. That will take me over to the Buy page for SLB.
From here, I can choose my region, choose which two zones I want to support. In my case, I want zones B and C, and I need to choose a specification for this instance. Okay, so let's see, I want to have a small. Each of these specifications supports a different number of connections per second, queries per second, and max connections. So for instance, the small can handle up to 5,000 connections at a time. The high one can handle up to 200,000 connections at a time. So there is a pretty significant difference between these classes.
For me, for the demo, I'll just go with small one, and I'm choosing internet, which means that there will be a charge for using this instance. If I were to choose an intranet, then it would be free because it would not be public facing, but I want an internet facing SLB instance so that I can show you SLB easily. I'll be using the SLB public IP address in a few minutes from within the browser to show you how the load balancing is working. So I want a public instance. I just need one. We'll create just one. And again, I want to make sure that it is using zones B and C because that's where my ECS instances are.
So I'll now click on Buy Now, and that should go ahead and let me proceed to the Checkout page. Once I agree to the Terms of Service, I can click on Activate. Once I've clicked on Activate, the process of creating my server load balancers should go ahead and start. So I can now close this tab and go back to the Server Load Balancer home page and Refresh, and sure enough, there is my load balancer. Of course, it's not going to work yet because I haven't configured the backend servers and I haven't configured any listeners.
So we need to fix that. So I'll click on the load balancers name here, its ID. And the first thing I want to do is create a virtual server group that contains my two ECS instances. So I'll click Create VServer Group and I'll call it web-servers, and I'll click on Add here, and I should be able to select from the ECS instances I have running in Singapore. I just have these two. So I'll check Select All, go to Next. I'll make sure they have the same weight so they each get the same number of requests. And they should be listening for incoming connections on Port 80, and I'll click Add. And then I will click Create to create that VServer group. And now that that's ready, I can go ahead and set up a listener.
So we're not quite done. We have a VServer group, but we also need to configure the listener to make sure that the load balancer is actually ready to listen for incoming requests on its public IP and distribute them to the servers in this group. So I'll click on the Listener tab, click on Add Listener. And we'll be creating an HTTP listener. We will listen externally also on Port 80, and I'll call this web-listener. The scheduling algorithm will be Weighted Round-Robin. If I want to click on that, I can click Modify, and then choose a different scheduling mechanism. In my case, Weighted Round-Robin is fine. I don't need to enable any of these other things like Session Persistence, Redirection or Access Control, although I could if I wanted.
I can also choose which HTTP header fields to modify or forward to my backend instances, et cetera. I'm going to leave all of that at the default settings. I'll click Next. Which VServer group do I want to route traffic to? It should go to my web servers group. Great. I'll click Next. And then I can set up my health check. In my case, my health check will be an HTTP health check and the health check path will just be the root. So basically, I will just send my HTTP requests to the web server root. I won't be trying to hit a particular webpage. And if I get a 3XX or a 2XX response back, then we'll consider the instance healthy. I'll click Next.
Okay, this summarizes all of the protocol, listener and health check information. Also gives me a list of my backend ECS instances. Once I've confirmed that all of this is set up the way I want, then I click Submit. And that will actually put our server load balancer into a configuration where it's ready to use. So if I now copy paste this IP into a web browser, I can see that I can now see the webpage that's being hosted on my backend servers. And if I refresh a few times, you should start to see that connections are in fact being distributed evenly between these two instances. So if I keep refreshing the page, sometimes I end up having my request forwarded to Instance A, other times the request goes to Instance B. And it looks to be about 50% of the time I go to A, and 50% of the time I go to B, which is correct.
If I wanted, I could change the weightings here in my listener, so that the traffic wouldn't be distributed evenly between these two instances. So let's actually do that. So I'll go do that from the VServer Group. So I can make, let's say that I want ECS A to get, whoops, has to be out of a hundred. Let's say he gets 80% of the traffic and Instance B only gets 20%, and then I'll Save. Now that I've made that change, let's see what happens. So now, it's A most of the time and then occasionally B. And you can see the requests are being distributed according to the ratio that I configured. So everything is working. And that's it. That's how you configure and use Server Load Balancer.
Alibaba Cloud, founded in 2009, is a global leader in cloud computing and artificial intelligence, providing services to thousands of enterprises, developers, and governments organizations in more than 200 countries and regions. Committed to the success of its customers, Alibaba Cloud provides reliable and secure cloud computing and data processing capabilities as a part of its online solutions.