Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

4 Answers 4

up vote 8 down vote accepted

(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.

share|improve this answer
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

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.

share|improve this answer

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!

share|improve this answer

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.