Simple Apache Load Balancing – Pound RPM

1

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.

Simple Apache Load Balancing
Simple Apache Load Balancing

1. When the clients request the web content over the internet, requests go to the Pound Gateway ( Public Main Server) 202.148.202.3 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.

For 192.168.0.151

# echo "This is 192.168.0.151" > /var/www/html/index.html

For 192.168.0.152

# echo "This is 192.168.0.152" > /var/www/html/index.html

Restart the Apache server.

/etc/init.d/httpd restart

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

Install Pound

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

Configure 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.

vi /etc/pound.cfg

Modify the configuration file.

ListenHTTPAddress 202.148.202.3
Port 80 End
ListenHTTPS
Address 202.148.202.3Port    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://202.148.202.3, 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.

Extras

For Example, if you want to use Pound Gateway as one of the internal web server (202.148.202.3); 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 202.148.202.3
Port 80 End
ListenHTTPS
Address 202.148.202.3Port    443
Cert    "/etc/pki/tls/certs/pound.pem"

End

Service

BackEnd
Address 202.148.202.3

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.

Credit

Image is taken from YouTube Channel NetworkNutsDotNet

That’s All.

 

Further Reading

You might also like