Re: HAProxy, NGINX and Rails anyone?

From: Brian Gupta <>
Date: Wed, 30 Jul 2008 13:19:04 -0400

On Mon, Jul 28, 2008 at 8:57 AM, Patrick Viet <> wrote:
> Yes : don't use haproxy.
> Why would you want to use haproxy over nginx when nginx can already do your
> balancing ?
> Sure, haproxy is a little faster than nginx, but if nginx is there anyway,
> just use it.
> That will definitely be lighter.

Nginx's load balancing algorithm's is fairly simplistic. If you are going to be seeing any sort of sustained traffic, and are running with more than 2 or three backend mongrels, Rails can really benefit from haproxy's ability to limit connections to a single connection per back end rails/mongrel instance. (Fro those that don't know each backend Rails instance is a single threaded app. So they can only handle one web request at at time. If more are sent the go into a block IO wait state.)

Where this really helps is when a web request that initiates a 10-30 second database query. The slow web request isn't gonna stall any other web traffic as haproxy won't send any additional traffic to that webserver instance until that request either times out or is fulfilled.

In addition for those cases when you have bursts of traffic that temporarily overwhelm your backend, Haproxy queues those overflow connections on the front end and then drains them off to the backend mongrels in the most efficient and expedient manner. (So the end user experience is the best).

That all said, I still run with nginx in front of haproxy to intercept statics, and do SSL offload.


P.S. - It all really depends. You might want to start with just haproxy, if it is a small internal site, but if you plan to see any level of internet scale traffic, you are really gonna want to add haproxy into the mix.

> Patrick
> On Mon, Jul 28, 2008 at 2:21 PM, Redd Vinylene <>
> wrote:
>> Hi there!
>> I'm working on my first HAProxy, NGINX and Rails setup, and I was
>> wondering if anybody could help me improve my configuration:
>> I wish to keep things as simple as possible, but from what I hear, I'm
>> lacking quite a few "exciting" options ;)
>> -- Redd Vinylene

- Brian Gupta
Received on 2008/07/30 19:19

This archive was generated by hypermail 2.2.0 : 2008/07/30 19:30 CEST