Designing any scalable web architecture would be incomplete without investigating â€œload balancersâ€. There used to be a time when selecting and installing load balancers was an art by itself. Not anymore.
A lot of organizations today, use Apache web servers as a proxy server (and also as a load balancer) for the backend application clusters. Though Apache is the most popular web server in the world, it also considered over-weight if all you want to do is proxy a web application. The huge codebase which apache comes with and the separate modules which need to be compiled and configured with it, could soon become a liability.
HAProxy is a tiny proxying engine which doesnâ€™t have all the bells and whistles of apache, but is highly qualified to act as a HTTP/TCP proxy server. Here are some of the other wonderful things I liked about it
A few other notes
Finally a sample configuration file with most of the features I mentioned above configured for use. This is the entire thing and should be good enough for a production deployment with minor changes.
log loghost logfac info
listen http_proxy 0.0.0.0:8000
option httpchk HEAD /app/health.jsp HTTP/1.0
cookie SERVERID insert
capture cookie JSESSIONID len 50
capture request header Cookie len 200
capture request header Host len 50
capture request header Referer len 200
capture request header User-Agent len 150
capture request header Custom-Cookie len 15
appsession JSESSIONID len 32 timeout 3600000
server server1_name server1:8080 weight 1 cookie server1_name_cookie check inter 60000
server server2_name server2:8080 weight 1 cookie server2_name_cookie check inter 60000