8

In our environment we us both Nginx and HA Proxy on different clusters. Are there advantages of using one over the other?

Or, what is the best way to go about load balancing a basic LAMP server cluster?

Jason
  • 83
  • 1
  • 3

4 Answers4

8

(I'm not going into the "best way to load balance", since that's obviously situation specific.)

Both HAProxy and nginx are excellent choices for open-source HTTP load balancers on Unix. At a very high level, the pros and cons that come first to mind are IMHO:

nginx:

  • Can do SSL offloading (often a biggie).
  • Has a rich set of content processing modules, i.e. header rewriting, content compression, etc.
  • Can sometimes be 'the only HTTPd you need', making administration simpler if you don't need any other HTTPd's.
  • More extensible with plugins, f.x. for routing traffic.

HAProxy:

  • Can offer higher single-server performance than nginx (especially when running in TCP mode, 10gbit/s has been demonstrated).
  • IMHO simpler to get up and running for basic plain HTTP load balancing setups.
  • Changes a bit less, especially the slightly older stable branches often go for a while without needing security & stability updates.

But as said, both are excellent choices. Pick the one you feel most comfortable with.

  • 1
    Compression is a big plus for nginx so I ended up going: haproxy + nginx to have simple failover (haproxy) and gzip compression (nginx). – Alexis Lê-Quôc Apr 16 '12 at 14:58
2

That really depends on what you want to do.

Nginx can split load between clusters, as well as route specific domains to different clusters. Our nginx performance has been satisfactory. It's more like a load router.

For haproxy I know it queries the server status constantly, and will check the server before directing traffic to it. It also has an interface where you can view statistics. nginx I don't think does this on either score.

Jason Berg
  • 19,084
  • 6
  • 40
  • 55
Daniel Baker
  • 309
  • 2
  • 3
1

We use nginx as a webserver, and are very happy with it. I'm never going back to Apache. The downside is if you're intent on running PHP; it requires some hackery-jiggery to make it work under fastCGI.

Don't forget to put Varnish in place for caching! That simple step solves a lot of the problems of sites being Slashdotted/Fireballed!

gWaldo
  • 11,957
  • 8
  • 42
  • 69
0

I'm not an expert on this, but as far as I know HAProxy has better performance and is more configurable in how it does the load balancing.

Now I could throw a list of comparisons and benchmarks at you but I'll just link the google results instead https://encrypted.google.com/search?q=nginx+vs+haproxy

Not Available
  • 226
  • 1
  • 16