Practice 3 - Load balancing
Introduction
In this lab we will set up a load balanced network of application servers. You will set up an instance with a simple PHP application, join it to an existing load balancer group and test that everything is working as expected.
We will use Apache web server with PHP for the application and nginx for the load balancer.
Exercise 3.1. Setting up an Application Server instance
- Start an instance either from your previous snapshot or create a new clean instance from Ubuntu 14.04 LTS image.
- Make sure you use a security group that has port 80 open, like the security group you made last practice session!!
- Install the required software packages:
- Refresh the list of software packages:
sudo aptitude update
- Install the following ubuntu packages:
apache2, php5, libapache2-mod-php5
- Refresh the list of software packages:
- Restart apache web server:
sudo /etc/init.d/apache2 restart
- Delete
/var/www/html/index.html
- Download index.zip
- Unpack it and upload the cointaining
index.php
file to the instance usingscp
(or just copy its content) and move it to/var/www/html/index.php
- Alternatively you can use
wget
to download the zip directly to the instance andunzip
to unpack it.
- Unpack it and upload the cointaining
- Create an empty data file:
/var/www/html/data.txt
- This file is used to store the list and count of incoming user requests.
- Change the owner of the created file to 'www-data':
sudo chown www-data /var/www/html/data.txt
(Apache web server is running under this user)
- Access your instance through a web browser using its Public IP to check that the website is working as required
- Modify
/var/www/html/index.php
to make the web page more personal to you, so that others would recognize that this application server was set up by you when they visit the page.- How you decide to modify it up to you, but there should at least be your Full Name present.
- You may want to make it visually very recognizable to differentiate between your server and other students servers more easily.
Exercise 3.2. Joining the load balanced group of Application Servers
Load balancer distributed all user requests of the web page across multiple application servers. Load balancers are used to increase capacity (concurrent users) and reliability of applications.

(image taken from http://www.netdigix.com/linux-loadbalancing.php)
- We are using Nginx (http://nginx.org/en/) as a load balancer.
- Load balancer address is http://172.17.136.3/
- To join your application server to the load balanced group of application servers, go to your lab assistant and tell them your application server`s private IP.
Exercise 3.3. Monitoring user traffic
- Visit the load balancer multiple times. Do you recognize your own application sever?
- Wait until you start seeing requests on your application server tracker from a number of other locations.
- You can check current incoming http connections using the following command:
netstat | grep http
- Take a screenshot of the output of this command. Try to have it display more than 4 connections when other student`s requests are being redirected to your server.
Exercise 3.4. Generating additional user traffic for benchmarking
- Your task is to generate a large number of user requests to the load balancer and verify how many of those requests are sent to your application server by the load balancer.
- To generate a large number of user request, you can either use existing load generation tools, web applets or write a simple script to visit the load balancer page.
- Note down how many of those requests end up on your application server. How large percent of your generated user requests ended up visiting your server?
- Take a screenshot of the tool or a script that you used for load generation.
Deliverables
- This time leave your instance running unless otherwise instructed so by the lab assistant
- Screenshot of your application server directly without load balancer
- It has to display incoming traffic from multiple locations and through the load balancer! You should wait until other students have visited load balancer and been redirected to your Application Server.
- Screenshot of seeing your page through the load balancer (Browser is directed at the load balancer IP address)
- Screenshot taken of the netstat command in exercise 3.3
- Screenshot taken in exercise 3.4 of the load generation tool.
- Also provide an answer for the following question:
- Explain in general terms how would you extend this kind of system (consisting of a load balancer and a number of application servers) to dynamically (and automatically) scale up or down depending on the number of user requests. (Size of the answer should be around two paragraphs)
Sellele ülesandele ei saa enam lahendusi esitada.