Simple Apache Load Balancing – Pound RPM
Load balancing is the method of distributing the requests that came from the clients to the multiple internal servers, and those servers serve the same content to the clients. Load balancing widely used with the web server where the web content served by multiple internal servers to the clients via the main public server.
The main public server acts as a proxy for Apache server to serve the web content, and main public server must have load balancer package installed on it. The pound is one of the packages that help you to setup the load balancer for the web server, it provides reverse proxy and also supports HTTPS requests. It works like below.
1. When the clients request the web content over the internet, requests go to the Pound Gateway ( Public Main Server) 184.108.40.206 at port no 80 or 443.
2. Pound gateway already configured with the internal servers (192.168.0.151 and 192.168.0.152)
3. Pound gateway forwards all the queries to the internal servers port no 80 or 443.
4. Pound gateway will do reverse proxy to deliver web content back to clients.
Install Web Server
Install Apache server on both internal servers using the yum command.
# yum install httpd
Place test index.html under /var/www/html on internal servers.
# echo "This is 192.168.0.151" > /var/www/html/index.html
# echo "This is 192.168.0.152" > /var/www/html/index.html
Restart the Apache server.
Verify the web servers by visiting http://192.168.0.151 and http://192.168.0.152; it should show “This is 192.168.0.151” and “This is 192.168.0.152” respectively
Pound does not bundle with the CentOS or Red Hat package, so you need to set up the extra repository package.
Download the EPEL repository rpm.
# rpm -Uvh http://kartolo.sby.datautama.net.id/EPEL/6/i386/epel-release-6-8.noarch.rpm
Install Pound rpm.
# yum install Pound
pound.cfg is the configuration file and can be found inside /etc directory, open up the configuration file to distribute the requests between the internal servers. You can also use HTTPS requests to distribute between the servers. If you don’t have SSL then put Address 0.0.0.0 on ListenHTTPS field.
Modify the configuration file.
ListenHTTPAddress 220.127.116.11 Port 80 End ListenHTTPS Address 18.104.22.168Port 443 Cert "/etc/pki/tls/certs/pound.pem" End Service BackEnd Address 192.168.0.151 Port 80 End BackEnd Address 192.168.0.152 Port 80 End End
Now visit http://22.214.171.124, refresh the page continuously. You could the see the home page of the internal web server, at the same time you can notice that homepage continuously changes on every request.
For Example, if you want to use Pound Gateway as one of the internal web server (126.96.36.199); make Apache web server to listen on some other port instead of port 80 because Pound uses port 80. Below is the small configuration to act as both ( Pound gateway and Web Server). Pound listens on Port 80 at the same time Apache listens on Port 808.
ListenHTTPAddress 188.8.131.52 Port 80 End ListenHTTPS Address 184.108.40.206Port 443 Cert "/etc/pki/tls/certs/pound.pem" End Service BackEnd Address 220.127.116.11 Port 808 End BackEnd Address 192.168.0.152 Port 80 End End
The load balancer is the most important solution in an enterprise environment where servers get million’s of requests, it ensures the client to get the web content on time and also free up the load on servers.
Image is taken from YouTube Channel NetworkNutsDotNet