By Alain Francois
All organizations use a variety of business-critical databases and applications, such as data warehouses, e-commerce applications, etc. There is an expectation that these systems are always working, and there will never be any downtime even if it is impossible to rule out entirely. However, the IT team is responsible for minimizing the risk of that happening. You need to eliminate single points of failure to achieve this. This way, if one element goes down, such as a server, the service is still available. That's why you need to implement high availability to prevent such disasters from happening. Cloud computing has been used by different types of clients because it has many advantages, and high availability has been one of the biggest challenges. Alibaba Cloud offers Server Load Balancer (SLB) to implement a high availability solution.
Server Load Balancer is a traffic distribution and control service that automatically distributes inbound traffic across multiple web-based applications, microservices, or containers hosted on Alibaba ECS instances. You can use SLB to prevent service disruptions caused by single points of failure (SPOFs) and improve the availability of applications as the distribution traffic is done across groups of backend servers to improve the service capability and application availability.
Alibaba Cloud provides two types of Server Load Balancer (SLB) instances:
The chart below shows some differences between ALB and CLB:
Since an SLB is a group of servers, you need to create two ECS instances as our web server first.
This guide will configure the high availability of web servers with SLB. If you want to do this, you need to:
We need to create two ECS instances in which we will install Nginx as the web server for test purposes.
Log into your Alibaba Cloud account and go to the _Elastic Compute Service_:
On the left panel, scroll to Instances & Images and select Instances to create a new ECS instance:
We will create Pay-As-You-Go instances. We will create each instance in a different zone but with the same VPC:
Select the operating system and define the disk size:
Select the VPC that will be used for your instance:
Configure if you will access your ECS with a password or a public key:
In the next step, you can select the default resource group:
You will see a review of your ECS configuration and order:
Now, you can see your new instance. Make sure to take the public IP for the remote access later:
Access your server with SSH and update the system package manager to install Nginx. Those operations should be done on the two ECS instances:
$ sudo apt update && sudo apt install nginx
List the default application recognized by ufw to allow the appropriate protocol:
$ sudo ufw app list
We will authorize the profile Nginx Full
to allow web access for the HTTP and HTTPS protocols:
$ sudo ufw allow 'Nginx Full'
You also need to authorize the SSH protocol if we don't want to lose our remote access:
$ sudo ufw allow 'OpenSSH'
Restart the firewall:
$ sudo ufw disable && sudo ufw enable
Start the Nginx service:
$ sudo systemctl start nginx
Enable it on the startup:
$ sudo enable nginx
We will edit the default page of our web page and indicate the web-server1 and the web-server2 to have a good view of the load balancer after setting it up. Edit the line listed below to achieve that:
$ sudo vim /var/www/html/index.nginx-debian.html
.....
.....
<h1>Welcome to nginx! demo web-server1</h1>
.....
.....
Open your browser and try to access Nginx with http://IP-SERVER
:
Test the same on the second webserver:
Now that the job is done on the two servers, let's configure SLB.
As explained, there are two types of SLB. In our case, we will need the Alibaba Cloud Application Load Balancer (ALB) for HTTP High Availability because it supports HTTP and HTTPS protocols. So, we will create an ALB instance:
You will see the SLB homepage. Now go to the ALB instance to create one:
You will need to select some values that we will explain:
You will see a review of your order. Confirm it. You can go back to the SLB overview menu page:
You can see the detail of the instance if you go back to the ALB instances menu:
SLB also consists of backend servers in our server group. It means we need to create a server group that will contain our two Nginx ECS instances. Go to the ALB server groups to create one:
Add the following parameters:
● Server Group Type: Instance to manage our ECS
● VPC: The same VPC as the ECS instances
● Backend Server Protocol: HTTP for this case
● Scheduling Algorithm: Weight Round Robin will help select how the requests will be forwarded to the backend servers. When adding backend servers, we will need to indicate the weight for each server. The default value is 100. The greater the weight of a server, the more requests are forwarded. It can help to define a main server.
● Resource Group: Select one
● Session Persistence: Let it be disabled. When it's enabled, ALB will forward all requests from a client to the same backend server meaning the backend servers may not be balanced.
● Configure Health Check: We will enable it, and the default health check settings will be used.
● Advanced Configurations: You can go there for more configurations:
/
by default.When you select _Create_, you will be prompted to add the backend servers to the new server groups:
Alternatively, you can go through the new group servers we just created:
You can add the backend servers:
Make sure to indicate the weight of each server to forward the requests:
You can see your backend servers added to the SLB:
After creating the group and backend servers, we need to create a listener so the SLB instance can listen to the ECS instances. Go back to the ALB instance menu and click on our instance:
Select create a listener:
You will have to configure the listener by indicating the protocol and the port number on which it should listen:
You need to select the server group. It will automatically list the backend servers and the status of each server:
You will have to confirm the configuration:
You will receive a confirmation prompt:
Once your listener is created, you need to find the virtual IP address or the virtual domain name of the Server Load Balancer that was automatically created. You can see if the requests will be forwarded to the backend server. Go to the instance details menu. You will see the virtual domain name that has been mapped to the virtual Elastic IP assigned on the vSwitches when creating our SLB instance.
Enter the virtual domain name to the browser to see if your SLB configuration works http://virtual-SLB-domain-name
. If you refresh the page continuously, you will see that the requests are forwarded to each server of the server group. You can decrease the weight of one server to have a different result.
Since the generated virtual domain is too complicated, if you can use your clients to access your website, you can set up the domain name for the website by creating a CNAME record that will be bound to the virtual domain created for the SLB instance.
High availability on the cloud is achieved by creating clusters and being a group of servers that act as a single server to provide continuous uptime. Alibaba Cloud has added increased hardware and platform stability for applications, developers, and enterprise users with the solution provided.
How to Monitor an Alibaba Cloud AsparaDB RDS Instance with CloudMonitor
1,042 posts | 256 followers
FollowAlibaba Clouder - November 29, 2017
Alibaba Cloud_Academy - July 16, 2020
Alibaba Clouder - December 31, 2020
Alibaba Clouder - March 2, 2021
Alibaba Clouder - March 3, 2021
Alibaba Clouder - April 23, 2018
1,042 posts | 256 followers
FollowRespond to sudden traffic spikes and minimize response time with Server Load Balancer
Learn MoreApplication High Available Service is a SaaS-based service that helps you improve the availability of your applications.
Learn MoreElastic and secure virtual cloud servers to cater all your cloud hosting needs.
Learn MoreMore Posts by Alibaba Cloud Community