×
Community Blog Use of Server Load Balancers to Regulate Network Traffic

Use of Server Load Balancers to Regulate Network Traffic

Solution: Edwin creates 4 ECS instances and installs NGINX browser. Then he uploads the website contents in all the ECS instances.

Server Load Balancer (SLB) is used to regulate network traffic to cloud services in Alibaba Cloud. When the traffic to ECS instances increases, we scale up with the number of instances to ease the tensions with the existing level of resources. In this scenario, SLB is needed to regulate the traffic and to check the quality of ECS instances by performing health check. In this blog we walkthrough a scenario of issues faced by a customer and learn on how it was solved.

Scenario
Stephen Koh runs a website for his jewelry shop in Singapore. For the Chinese New Year, he announced an online promotion and plans to have a different sales campaign every first week of the month. He is now anxious about the web application as there will be a huge traffic where he calculates as 4 virtual machines are needed. He wants machine number 2 to get more data requests than others. The distribution of requests for each of his machines is set to equal priority. His cloud engineer Edwin Tan also agrees the need and provides a solution.

Solution
Edwin creates 4 ECS instances and installs NGINX browser. Then he uploads the website contents in all the ECS instances. Then he uses Server Load Balancer to provide the distribution of traffic.

Procedure
Go to ECS console and create 4 ECS instances in Singapore region.
blogpic

blogpic
Choose Ubuntu OS and the version of your choice.
blogpic
Specify the VPC they belong to. VPCs are created earlier.
blogpic
Set the log on credentials.
blogpic
Enter appropriate details and create the ECS instances.
blogpic
Rename the ECS instances for easy understanding.
blogpic
Now we need to install Nginx and install the web hosting environment. For each ECS instance, follow the steps as below. Enter the command prompt and login to the ECS instance.
blogpic
Update the linux distribution using apt update in the command prompt.
blogpic
Install NGINX using apt install -y nginx .
blogpic
Enter the html markups using the command vim /var/www/html/index.html
The home page is available in some default name in html folder. That file could be used or a new file created and the former is removed.
blogpic
Associate an Elastic IP (EIP) with each instance. Make a purchase of sufficient number of EIPs from the console earlier.
blogpic
Now copy the EIPs of each ECS instance and check the browser.
blogpic
Enter into the console of Server Load Balancer.
blogpic
Click on to the Classic Load Balancer (CLB). This is good enough for a normal website.
blogpic
Click on Create CLB.
blogpic
blogpic
Click on “Buy Now”.
blogpic
Agree to the Terms of Service and click Activate Now.
blogpic
SLB is created now. Click on Add Backend Server and add ECS instances.
blogpic
Check on the ECS instances to add and click Next.
blogpic
Click Add and then OK.
blogpic
Click on Listener tab.
blogpic
Click on Add Listener.
blogpic
Click on HTTP and enter the listener port as 80.
blogpic
Click Next.
blogpic
Click on Default Server Group. Enter the port number as 80 and enter the weight as listed in the scenario.
blogpic
Click Next.
blogpic
Click Next.
blogpic
Click Submit.
blogpic
Click OK. Go to the SLB instances.
blogpic
Copy the IP and enter into a browser. Refresh the page and see the pages loading from various ECS instances.

0 1 0
Share on

ferdinjoe

17 posts | 19 followers

You may also like

Comments