DEMO: Server Load Balancer
Alibaba Server Load Balancer
The course is part of this learning path
This course provides an introduction to Alibaba's Server Load Balancer service, also known as SLB. The course begins with a brief intro to load balancing in general and then takes a look at Alibaba SLB and its three main components. We'll look at how SLB can be used for high availability, fault tolerance, and disaster tolerance. You will also learn about SLB instance clusters, traffic routing, and security, before finally moving on to a demonstration from the Alibaba Cloud platform that shows how to set up a Server Load Balancer with two servers.
If you have any feedback relating to this course, please get in touch with us at firstname.lastname@example.org.
- Learn about load balancing and Alibaba's Server Load Balancer (SLB) service
- Understand the three main components of SLB
- Learn about high availability and fault tolerance with Alibaba SLB
- Learn about the running and operations of SLB
- Set up a Server Load Balancer
This course is intended for anyone who wants to learn about the basics of Alibaba's Server Load Balancer service and how to use it.
To get the most out of this course, you should have a basic understanding of Alibaba Cloud. Some knowledge of load balancing would also be beneficial.
Hello, and welcome to session five, the last session in this series. In this session, I will demonstrate setting up a server load balancing solution in the Alibaba console. I'll be using two pre-created servers in the London region. One server resides in zone A and the other in zone B. In a production environment, backend servers would be serving the same content and the load balancing service would be transparent to the end user. For demonstration purposes, both servers have slightly different static webpages so that we can see the effect of load balancing taking place.
Before creating the server load balancer, let's look at each service webpage to make sure the content is being displayed. Here you can see I'm in the console for the elastic compute service, and I can see my two ECS instances that are currently running. I have web two in zone B and web one in zone A. And what I'm gonna do is copy the IP addresses, these are the public IP addresses, so that I can then go and look at the static web content that's running on web two. And if I come back and do exactly the same for web one, yeah, you can see that I've got web one running and web two running with the slightly different static web pages that they're serving.
So, the idea is that we now want to go and create a load balancing solution that will balance across the two backend servers, because currently to get access to those, I need to know their public IP addresses and navigate to them individually, or their fully qualified domain names if it was set up in DNS.
Okay, so let's go and create the SLB instance. I'm just gonna select the menu system, go down and select server load balancer. And that takes me into the server load balancer console where we're gonna select create instance. Now that app does up the build template. And the first thing we need to do is select the region that we want the instance to be created in.
Now, I'm gonna select the U.K. London region because that's where my ECS instances are running. And you can see that the zone type is set to multi zone. Apart from UAE, all of the zones support multi zone, which means we have a primary zone and a backup zone, and you get to choose which one you want as the primary, or as the backup. I'm gonna choose A as the primary and B as the backup, for example. Then all I've got to do is give it an instance name. And then we need to choose the instance type, whether we want it to be public facing or private facing. So, I'm gonna select the default of internet to make it public facing. And we then need to check the instance type that I want to run.
Now, the shared performance instance will allow us to have a cheaper option and it shares hardware that other SLB instances are using, or we can choose a guaranteed instance which give us a guaranteed performance. And there are six different levels of guaranteed instance that you can choose from. I'm just gonna select the smallest of the guaranteed instances. And then, the next thing to choose is whether we want to pay by traffic or pay by bandwidth.
Now by traffic, the default is that there is a cost per hour and also a traffic fee cost per gigabyte. And by bandwidth, you'll see the calculated cost will now be per hour. I'm just gonna leave it at the default by traffic. Optionally, I can select a resource group and I can select how many instances I want to create. If I select the buy now button, that will then take me to the confirm order page, where I can then check to make sure I've got everything set up the way I want it. I just have to then agree and I can click on the pay button. And that will create my SLB instance.
Now, it will take a couple of minutes for that to be created. It says the order's complete. I'm just gonna close that window down, go back into the management console and refresh the screen. And I now see my new SLB instance. So, what we've got to do now is configure it. Now you can see, I can configure from here. I can configure a listener from here. I can add a backend service from here, but the default is if I open the actual instance up, if there are no listeners configured, the first thing you have to do is have at least one listener configured.
So, I'm just gonna click on add listener. And you can see that we're now into the protocol and listener page where I get to choose the protocol I wish to use and also the port I wish to listen on. So, for this particular one, I have the option of either selecting TCP, UDP, HTTP, and HTTPS.
Now, once you've selected a protocol and added the port, so I'll just go at port 80, that's what we want to listen on, I have the option then of changing the, or modifying the scheduling algorithm that I wish to use.
Now for TCP, if I click modify, I have the option of Weighted Round Robin, Weighted Lease Connection, Round Robin, or Consistent Hash. If I was to select HTTP, you'll see consistent hash is taken out because it only works with TCP and UDP. So, for this particular one, I'm gonna go with HTTP. I'll leave it at Weighted Round Robin.
Now I could, now that I've selected HTTP, go and set up some of the other advanced settings in here. Not gonna worry about those too much, this just a basic intro. And I'm just gonna click next. The next bit we need to is add the backend servers. And from here, we have the option of a V server group or the default server group. And 'cause I've selected HTTP, the primary secondary server group is unavailable.
Now that's an active passive set of servers. You can only use two servers for that, right? One is active, the other one is idle until the first one fails. The second one comes online, takes over. And then, when the first one's repaired again and comes back online, it takes over again. That only works with TCP and UDP. So we're gonna select the default server group in here, and we now need to add the backend servers in.
So, when I click on add more, it will show me the servers that are in the London zone. If I select both of those servers and click next, it will add them into the backend pool effectively. And from here, I get to choose the weight. Now the default is 100, which means at the moment, we're looking at a Round Robin scenario because the weight numbers are the same. If I was to change that to 50, for example, then web two would have twice as more requests forwarded to it than web one. I'll leave those at the default settings.
Now, when we click on add to add those servers in, we now have to set up the port we want to forward to. So for this one, I want to, I'm listening on port 80 and I want to forward to port 80. Once we've done that, click next. So on this step, we're looking at the health check, which is enabled by default, basically before requests are forwarded to any of the backend servers, the SLB instance checks to see if those servers are still online. And it basically sends out every two seconds a health check. And as long as it gets a response from the service, it knows they're healthy. If it stops getting a response, it will stop sending requests to that server.
So, we're just gonna click next, and we then submit the settings to set up the listener. Okay, once that's been set up, we can click okay. The listener's then added in and our service is now online. Now, if I go back to the instance details, you'll see that under the information we have a public IP address. Now, if I go and select the public IP address and click go, it will open a new browser tab, and you can see I've been forwarded to web two in this instance. If I refresh the screen, you'll see that I'm redirected to web one. Now, they're both utilizing the same public IP address of the server load balancer. Unlike originally, when we were accessing the web service from their individual IP addresses, we can see here the first part of the demo. Okay, that concludes the demonstration on server load balancer.
A world-leading tech and digital skills organization, we help many of the world’s leading companies to build their tech and digital capabilities via our range of world-class training courses, reskilling bootcamps, work-based learning programs, and apprenticeships. We also create bespoke solutions, blending elements to meet specific client needs.