Using a load balancer
Websites that deal with huge traffic generally use a technique called load balancing to improve the availability and responsiveness of applications. A load balancer distributes incoming traffic among multiple servers hosting same content. The distribution of load is determined by various scheduler algorithms.
In this section, we will see how to add a load balancer in front of our application servers (assuming that they are running on the IPs 127.0.0.1
, 127.0.0.2
, and 127.0.0.3
on the port 9000
) using different HTTP web servers.
Apache HTTP
The Apache HTTP server provides a secure, efficient, and extensible server that supports HTTP services. The Apache HTTP server can be used as a load balancer through its mod_proxy
and mod_proxy_balance
modules.
To use Apache HTTP as a load balancer, mod_proxy
and mod_proxy_balancer
have to be present in the server. To set up the load balancer, all we need to do is update /etc/httpd/conf/httpd.conf
.
Let's update the configuration...