Our Blog

BY : developer 0 comment

Load Balancing Linux Apache Server Using Pound

Load Balancing is the method for workload distribution across computing resources, thus aiming to optimize the resource usage, producing a maximized throughput, minimal response time and to avoid overload of any of the resources. In the web, load balancing is the process of setting up a number of Web servers for the same web site, and distributing the Web traffic to these servers. It is a technique that is also used for reducing the downtime and the eventually the data loss. Load balancing is normally delivered by a dedicated software and I would like to write about one such software – POUND. A scenario is defined, and the implementation for load balancing, pound set up and configuration, with the final configuration testing is described below. It is beautiful!

SCENARIO

The diagram shows a POUND server accepting HTTP requests from Internet & Local LAN and serving the web contents. The Web Servers are in the local LAN serving the Web Pages. The Apache Web Server 1 will be serving more requests as compared to the Apache Web Server 2.

Operating System used:RHEL 6.2 in all the three systems.

POUND Server:- The machine is named server11.example.com and has the IP Address of 192.168.0.111

Apache Web Server 1:- The machine is named as server1.example.com and has the IP Address of 192.168.0.101

Apache Web Server 2:- The machine is named as server2.example.com and has the IP Address of 192.168.0.102

INTRODUCTION TO POUND

Pound is a reverse-proxy load balancing server. It accepts requests from HTTP / HTTPS clients and distributes them to one or more Web servers. The HTTPS requests are decrypted and passed to the back-ends as plain HTTP. Pound will thus act as:-

1. Server Load Balancer

2. Reverse Proxy Server

3. Apache Reverse Proxy

Pound detects when a back-end server fails or recovers, and execute load balancing decisions based on this information. Apparently, if a back-end server fails, it will not receive requests until it recovers.

It can decrypt https requests to http ones, rejects incorrect requests and also can be used in a chroot environment (security feature). And, if more than one back-end server is defined, Pound chooses one of them randomly, based on defined priorities. By default, Pound keeps track of associations between clients and back-end servers (sessions).

WHAT POUND IS NOT

1. Pound is not a Web server: by itself, Pound serves no content – it contacts the back-end server(s) for that purpose.

2. Pound is not a Web accelerator: no caching is done – every request is passed “as is” to a back-end server.

IMPLEMENTATION FOR LOAD BALANCING

Apache Web Server 1:

root@server1 ~]# rpm -qa | grep -i httpd
httpd-2.2.15-15.el6.x86_64
[root@server1 ~]#
[root@server1 ~]# mkdir /var/www/html/site1
[root@server1 ~]# echo "SITE1" > /var/www/html/site1/index.html
[root@server1 ~]#
[root@server1 ~]# vim /etc/httpd/conf/httpd.conf
<VirtualHost 192.168.0.101:80>
DocumentRoot /var/www/html/site1
ServerName server1.example.com
</VirtualHost>
[root@server1 ~]# httpd -t
Syntax OK
[root@server1 ~]# service httpd restart
Stopping httpd:[ OK
Starting httpd:[ OK
[root@server1 ~]# chkconfig httpd on
[root@server1 ~]# elinks --dump server1.example.com
SITE1
[root@server1 ~]#

Apache Web Server 2:

[root@server2 ~]# rpm -qa | grep -i httpd
httpd-2.2.15-15.el6.x86_64
[root@server2 ~]#
[root@server2 ~]# mkdir /var/www/html/site2
[root@server2 ~]# echo "SITE2" > /var/www/html/site2/index.html
[root@server2 ~]#
[root@server2 ~]# vim /etc/httpd/conf/httpd.conf
<VirtualHost 192.168.0.102:80>
DocumentRoot /var/www/html/site2
ServerName server2.example.com
</VirtualHost>
[root@server2 ~]# httpd -t
Syntax OK
[root@server2 ~]# service httpd restart
Stopping httpd:[ OK
Starting httpd:[ OK
[root@server2 ~]# chkconfig httpd on
[root@server2 ~]# elinks --dump server2.example.com
SITE2
[root@server2 ~]#

POUND SERVER

1. Make sure httpd package is not installed.

[root@server11 ~]# rpm -qa | grep -i httpd
[root@server11 ~]#

2. Download the Pound source rpm to the current location (/root) from the link

[root@server11 ~]# ls
anaconda-ks.cfg install.log install.log.syslog post.log pound-2.6-1.el5.src.rpm pre.log

3. Install rpm-build, gcc, openssl-devel and pcre-devel packages

[root@server11 ~]# yum -y install rpm-build gcc openssl-devel pcre-devel

4. Installation from a src.rpm package is an unorthodox way of installing a package. First, build the rpm from src.rpm package by using rpmbuild -rebuild.

[root@server11 ~]# rpmbuild --rebuild pound-2.6-1.el5.src.rpm
Installing pound-2.6-1.el5.src.rpm
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.I5xGdh
+ umask 022
+ cd /root/rpmbuild/BUILD
+ cd /root/rpmbuild/BUILD
+ rm -rf Pound-2.6
+ /bin/tar -xf -
+ /usr/bin/gzip -dc /root/rpmbuild/SOURCES/Pound-2.6.tgz
+ STATUS=0
+ '[' 0 -ne 0 ']'
+ cd Pound-2.6
+ /bin/chmod -Rf a+rX,u+w,g-w,o-w .
+ echo 'Patch #0 (pound-2.5-remove-owner.patch):'
Patch #0 (pound-2.5-remove-owner.patch):
+ /usr/bin/patch -s -p1 -b --suffix .remove-owner --fuzz=0
+ /bin/cat /root/rpmbuild/SOURCES/pound-2.5-remove-owner.patch
+ echo 'Patch #1 (pound-2.6-gcc.patch):'
Patch #1 (pound-2.6-gcc.patch):
+ /usr/bin/patch -s -p1 -b --suffix .oldgcc --fuzz=0
+ /bin/cat /root/rpmbuild/SOURCES/pound-2.6-gcc.patch
+ /usr/bin/install -m 0644 -p /root/rpmbuild/SOURCES/pound.png ./
+ exit 0
<-- Output truncated ?
Executing(--clean): /bin/sh -e /var/tmp/rpm-tmp.lAWCcI
+ umask 022
+ cd /root/rpmbuild/BUILD
+ rm -rf Pound-2.6
+ exit 0
[root@server11 ~]#
[root@server11 ~]# ls -R rpmbuild/
rpmbuild/:
BUILD BUILDROOT RPMS SOURCES SPECS SRPMS
rpmbuild/BUILD:
rpmbuild/BUILDROOT:
rpmbuild/RPMS:
x86_64
rpmbuild/RPMS/x86_64:
pound-2.6-1.el6.x86_64.rpm
rpmbuild/SOURCES:
rpmbuild/SPECS:
rpmbuild/SRPMS:
[root@server11 ~]#

5. Installation of Pound rpm

[root@server11 ~]# rpm -ivh rpmbuild/RPMS/x86_64/pound-2.6-1.el6.x86_64.rpm
Preparing...########################################### [100%]
1:pound########################################### [100%]
[root@server11 ~]#
[root@server11 ~]# rpm -qa pound
pound-2.6-1.el6.x86_64
[root@server11 ~]# rpm -qc pound
/etc/pki/pound/pound.pem
/etc/pound/pound.cfg
/etc/rc.d/init.d/pound
[root@server11 ~]#

6. Now modify the configuration file. The settings has been shown in RED colour.

[root@server11 ~]# vim /etc/pound/pound.cfg
# Main listening ports
ListenHTTP
Address 192.168.0.111
Port80
xHTTP1
End
# Catch-all server(s)
Service
BackEnd
Address 192.168.0.101
Port80
Priority 7
End
BackEnd
Address 192.168.0.102
Port80
Priority 3
End
Session
TypeBASIC
TTL300
End
End
[root@server11 ~]# service pound start
Starting pound: starting... [OK]
[root@server11 ~]#

TESTING THE CONFIGURATION

Accessing the server11.example.com shows the first server response.

On refreshing the page we get to see the second server response as well. We could confirm the same from log as well

[root@server11 ~]# grep pound /var/log/messages
Dec 29 11:25:08 server11 pound: 192.168.0.254 GET / HTTP/1.1 - HTTP/1.1
200 OK
Dec 29 11:25:25 server11 pound: 192.168.0.254 GET / HTTP/1.1 - HTTP/1.1
200 OK
Dec 29 11:27:00 server11 pound: 192.168.0.254 GET / HTTP/1.1 - HTTP/1.1
200 OK
Dec 29 11:27:22 server11 pound: 192.168.0.254 GET / HTTP/1.1 - HTTP/1.1
200 OK
Dec 29 11:27:22 server11 pound: 192.168.0.254 GET / HTTP/1.1 - HTTP/1.1
304 Not Modified
Dec 29 11:27:23 server11 pound: 192.168.0.254 GET / HTTP/1.1 - HTTP/1.1
200 OK
[root@server11 ~]#

List of Authors

Load Balancing is the process of setting up a number of Web servers for the same website,

Leave a Reply

Your email address will not be published.

Tags

#aintegrateddigitlmarketing##ansibleautomates#AWS#blog#cicd#Container#DO180#DO280#ipsronlinetraining#kubernetes#OpenShift#OpenShiftTraining#pythonindemand##redhatautomation#redhatcertification#redhatcertification #redhatlinux #redhatsystemadministration #ansibleautomates #containers #kubernetes #RHCSA #RHCE #DO180 #DO280 #ipsr #ipsronlinetraining #openshift#RedHatLearningSubscription#redhatlinux#RedHatOpenShift#redhatsystemadministration#RedHatTraining#RHCE#RHCSA#RHLS#RHLSPremium#tiktokanalyticsandroidansiblearticleArtificial IntelligenceASP.NETaws online trainingbacklinkboot campcareercareer advancementcareer opportunitycertificationcloudclougcontainerscybersecurityCyberSecurityCertificationData Analysts in 2024data analyticsdata analytics certificationdata analytics trainingdemandDev-OpsDevopDevOpsDigital marketingdigital marketing courseDigital Marketing Salary in IndiaExam resultsfiles typesForrester ResearchindiaInfluencer MarketingInstagraminterview questionsinterview quetioninterview techniqueIOTipsrITit careerIT Finishing schoolsIT jobsIT proffessionalsITFSjavajob interviewjob opportunitiesjob opportunitiessjobskeywordKMEA Collegelearn python onlinelink buildingLinuxlinux online trainingLinux System Administrationmachine learningMastering DevOpsnetworkingonline python trainingopen sourcephytonplacementsPrivate Cloudpythonpython certificationpython certification coursePython in 2024python trainingRankingsRed HatRed Hat Academyred hat linuxRed Hat Linux TrainingredhatresultsRHCARHCE certificationrolessocial media marketing online coursesoftwarestudent poststudents postsuccess storiestablueThreads by Instagramtraining