EDIT: I'm interested in high availability, performance server setup.

I read a lot of articles about haproxy vs. nginx vs. apache etc. and this was my conclusion:

  1. haproxy is better load-balancer than nginx
  2. nginx is better web server than apache

So my question is that which setup is better?

  1. Using haproxy as load-balancer and nginx as web server?
  2. Using nginx as both load-balancer and web server?
  3. Using haproxy with apache?

My setup would be 2 separate servers with the following installed: load balancer, web server, PHP, MySQL for read

1 separate server for just MySQL write which then replicates to the 2 slave MySQL for read.

What do you think?

link|improve this question
1  
There is no definition for "better" in your context. The evaluation of software is a quite complex procedure and requires knowledge of so many details of your personal (planned) setup that nobody is going to be able to give you a comprehensive advice. This is the reason why questions of such kind are regularly closed on serverfault. – syneticon-dj Dec 8 '11 at 23:34
Ok, I edited my post. I'm interested in high performance, high availability server setup. where the web app. will process huge loads of XML files which then needs to be written in MySQL – feketegy Dec 8 '11 at 23:39
I need a car. It has to be fast and reliable. People are going to get in and out of it quite often and occasionally bring some baggage. Given all that, is it better to have the car fueled by gasoline or diesel? – syneticon-dj Dec 9 '11 at 8:56
Instead of such comments why wouldn't you tell me which setup do you prefer? Or how's your servers setup? – feketegy Dec 9 '11 at 10:33
Because it completely depends on your very specific requirements - that's what I am trying to tell you. If you have specific concerns like "I have a PHP/perl/CGI/ASP application using XYZ and here is my config which is broken for reasons so far mysterious to me - how do I get it running?" you should ask directly that way. If you need a general debate about advantages of one web server software against another, you've come to the wrong place. – syneticon-dj Dec 9 '11 at 13:57
feedback

closed as not constructive by Shane Madden, syneticon-dj, Iain, Ward, sam Dec 9 '11 at 11:39

This question is not a good fit to our Q&A format. We expect answers to generally involve facts, references, or specific expertise; this question will likely solicit opinion, debate, arguments, polling, or extended discussion. See the FAQ for guidance on how to improve it.

1 Answer

Haproxy and Nginx are not the same beasts : haproxy only deals with the network and never touches the filesystem. It will never serve static content for you. On the other hand, it will perform an order of magnitude higher than any full fledged HTTP server like Nginx and Apache.

Haproxy is also a sophisticated load balancer, you need to have some use to it.

In my case, I'll use nginx or Apache up to 10,000 simultaneous connections on single servers or trivial setups because it does the job nicely and all by itself. For more involved architectures (many servers, high throughput), a dedicated loadbalancer like Haproxy is desirable.

Nginx vs. Apache is a moot point IMHO. I can scale both to 10,000 concurrent clients on a decent server (say 4 cores and 4G RAM), and if Nginx is a bit lighter on ressources, it does not make the difference since most of the time the app (Rails, Django, PHP, whatever) is 90% of the CPU+memory burden.

I'll say : use the web server you're the most comfortable with. OTOH it's true googling for Apache recipes is full of bullshit and it requires to carefully read the (large and very good) doc. As an Apache dinosaur, I'm very satisfied with it. But if you're new to HTTP web servers, I guess Nginx is less intimidating and more cool. Both Apache and Nginx are extremely reliable.

As for PHP, I use Apache with a worker MPM and FastCGI. Simple, efficient. I've documented that a long time ago on http://forge.bearstech.com/trac/wiki/DebianLamp : it's even easier on Debian 6.0 but I've not documented it.

Your setup seems fine to me (Haproxy + Apache or Nginx, then PHP via FastCGI). It's a good idea to put the loadbalancer on every front server instead on a distinct node (which becomes a SPOF). And it's simpler since every node runs the same setup. Add a an IP fail over and you're done.

link|improve this answer
I'm thinking of putting haproxy in front of nginx and use PHP-fpm + MySQL for reading on each node, then create a dedicated instance for just MySQL for writing. – feketegy Dec 9 '11 at 11:49
feedback

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