Load balancing web server using POUND load balancer
Load balancers are used to improve the performance of infrastructure, whether they are being used to improve performance of a single system by distributing load across various network interfaces or load balancing might be used to distribute load of a web server across several backend servers.
A use case scenario for using Load balancing might be a website that attracts lots of traffic, using load balancing leads to increased server functionality, decreased traffic congestion which leads to faster page loading.
In this tutorial we are going to discuss POUND load balancer. Pound load balancer acts as a reverse proxy that evenly distributes incoming traffic/requests received from port 80 or 443 (or both) across two or more backend web servers.
When Pound Load balancer is configured, it will be the public facing server that means extra layer of security for websites as pound will act as a reverse proxy & when requests are received at Pound server, it will then evenly forward the requests to backend web servers & then replies back to end user after the requests have been processed.
Things you will need
To configure a pound server we will need following,
1- Two servers with Apache installed, these will acts our backend web servers,
2- A server with POUND load balancer installed.
We will using the following setup for setting up our load balancer,
Hostname- pound.unxschl.com IP address- 192.168.1.100
Hostname- web1. unxschl.com IP address- 192.168.1.111
Hostname- web2. unxschl.com IP address- 192.168.1.112
Step 1- Web Server Installation
Firstly we need to prepare apache web servers which will act as our backend machines. To install apache, run following command on both the servers,
|# yum install httpd
After installation has been done on both machines, we will move onto configuration part.
Step 2 – Web Server configuration
Next step is creating an Index.html file to identify both web servers. To create one, go to /var/www/html & create an index.html page using commands below,
|# cd /var/www/html
# echo “This is web server 1” > index.html
Similarly create index.html page on server 2 as well but change “This is web server 1” to “This is web server 2”
Restart apache services on both machines to implement the changes,
|# systemctl restart httpd
We can check if the index.html pages are working or not by entering the IP address or FQDN (Fully Qualified Domain Name) of the machine into your internet browser.
Step 3 – Pound server Installation
To install Pound server, we first have to enable EPEL repository as Pound Load balancer is not available with default repositories. To enable EPEL repository, run
|# rpm -Uvh https://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-8.noarch.rpm
Once the repo has been installed, we will install pound by running,
|# yum install pound
Step 4 – Pound server configuration
The configuration file for Pound load balancer is /etc/pound.cfg. To configure load balancing, we will edit this file,
|# vi /etc/pound.cfg
Now make changes to the file as done below,
Save the file & exit it.
NOTE:- Remove the section with ListenHTTPS if not using HTTPS.
Now restart the pound services to implement changes to the configuration file,
|# systemctl restart pound
Step 5 – Testing the load balancer
Now to make sure that our load balancer is properly configured & working fine, we will test the load balancer. To test the load balancer, open the web browser & enter the Pound server’s IP address i.e. 192.168.1.100. It will open the web page saying “This is web server 1 ”, refresh the page & you will then be redirected to web server 2, keep refreshing & you will see that one request goes to server 1 & then to server 2. So that means our Pound load balancer is working as it is supposed to.
This completes our tutorial on Pound Load balancer. If you are having any doubts/questions, feel free to mention them in the comment box down below.