Linux – a load balancing scenario using HAProxy and keepalived shows no performance advantage

haproxylinuxload balancing

I am trying to setup a load balanced web server scenario, using two HAproxy load balancers and two debian web servers following this guide http://www.howtoforge.com/setting-up-a-high-availability-load-balancer-with-haproxy-keepalived-on-debian-lenny.

the setup is working but the results of simple performance benchmarking is not what I expected. I tried apache benchmark tool to send lots of requests to servers (one time directly testing one of the web servers and the other time testing through the load balancer) using the command "ab -n 1000000 -c 500 http://IP/index.html", but the test results shows better performance for the single server without load balancer. can any one tell me if I'm going wrong on some thing?

Best Answer

My understanding is that haproxy is a load balancer, the benefits of which are scaling and redundancy NOT performance.

To bench the effects of your load balancer you should run you should first bench the faster of your servers, increasing the load until you find the point at which it falls apart. Then start at that point when you bench haproxy, you should be able to handle approximately twice the amount of connections.

To increase the speed you want a caching reverse proxy such as nginx, varnish or squid.