1

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?

chakoshi
  • 49
  • 1
  • 2
  • 6
  • 1
    Is there anything related to sticking to the same server on haproxy ? (never used it, just read about it). If this is set by default, and your loadtesting is being made from the same ip, this could indicate same performance as without HA. To double check, you can also tail access_log on both servers to see if requests are being balanced according to your configuration. – Torian Jan 13 '11 at 18:59
  • yes, that's one of the things I checked, the requests are distributed to both servers, but I'm afraid the overhead/delay of a load balancer in the middle is more than the benefits of distributing the load on two servers as the current benchmarking is done by requesting a simple html file. may be trying to benchmark a php file with mysql connection stress the server processing much more, I'll try it and post the results – chakoshi Jan 13 '11 at 19:41
  • I would expect the overhead added by haproxy to be minimal. You can you post the actual results of the benchmarks? – Kyle Brandt Jan 16 '11 at 13:50
  • @kyle: I dont have the results available now, but the tests take about 30% longer on the load balanced system. of course I found that testing the servers for their highest capabilities is not that easy and I should make more considerations on systems settings (both test client and server) to make the test results valid. – chakoshi Jan 20 '11 at 09:41

2 Answers2

3

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.

Antonius Bloch
  • 4,680
  • 6
  • 29
  • 41
  • 2
    Absolutally correct. From a performance point of view, unless your server is currently over-utilised, adding haproxy will not increase performance at all. In fact, it adds additional overheads. – Mark Henderson Jan 13 '11 at 21:18
  • 1
    To be fair, a loadbalancer like haproxy will in a real-world scenario handle a lot of the IP and TCP cruft, giving the application servers more breathing room. – Joris Jan 13 '11 at 22:12
  • so if I get it right, you say that the load balanced scenario would show it's value after a certain load threshold, I'll try that. but as you named nginx, do HAProxy and nginx do the same job? I thought they are in a same group – chakoshi Jan 14 '11 at 18:53
  • 1
    @chakoshi: nginx has a lot of functionality, other than load balancing. haproxy has some specific features and properties. It depends on the situation of course. – Joris Jan 14 '11 at 22:12
1

To put it another way, unplug your primary webserver during the test. I think you'll find that the haproxy pair, even with the same server unplugged, now returns far better numbers overall.

RJStanford
  • 121
  • 2