views:

2868

answers:

6

We're running a Rails site at http://hansard.millbanksystems.com, on a dedicated Accelerator. We currently have Apache setup with mod-proxy-balancer, proxying to four mongrels running the application.

Some requests are rather slow and in order to prevent the situation where other requests get queued up behind them, we're considering options for proxying that will direct requests to an idle mongrel if there is one.

Options appear to include:

  • recompiling mod_proxy_balancer for Apache as described at http://labs.reevoo.com/

  • compiling nginx with the fair proxy balancer for Solaris

  • compiling haproxy for Open Solaris (although this may not work well with SMF)

Are these reasonable options? Have we missed anything obvious? We'd be very grateful for your advice.

+2  A: 

Apache is a bit of a strange beast to use for your balancing. It's certainly capable but it's like using a tank to do the shopping.

Haproxy/Nginx are more specifically tailored for the job. You should get higher throughput and use fewer resources at the same time.

Oli
+1  A: 

Hi, if you want to avoid Apache, it is possible to deploy a Mongrel cluster with an alternative web server, such as nginx or lighttpd, and a load balancer of some variety such as Pound or a hardware-based solution.

Pounds (http://www.apsis.ch/pound/) worked well for me!

VP
A: 

I've used mod_proxy_balancer + mongrel_cluster successfully (small traffic website).

marius
+1  A: 

HAProxy offers a much richer set of features for load-balancing than mod_proxy_balancer, nginx, and pretty much any other software out there.

In particular for your situation, the log output is highly customisable so it should be much easier to identify when, where and why slow requests occur.

Also, there are a few different load distribution algorithms available, with nice automatic failover capabilities too.

37Signals have a post on Rails and HAProxy here (originally seen here).

Alabaster Codify
+1  A: 

The only issue with haproxy and SMF is that you can't use it's soft-restart feature to implement the 'refresh' action, unless you write a wrapper script. I wrote about that in a bit more detail here

However, IME haproxy has been absolutely bomb-proof on solaris, and I would recommend it highly. We ship anything from a few hundred GB to a couple of TB a day through a single haproxy instance on solaris 10 and so far (touch wood) in 2+ years of operation we've not had any problems with it.

Chris May
A: 

Pound is an HTTP load balancer that I've used successfully in the past. It includes a dynamic scaling feature that may help with your specific problem:

DynScale (0|1): Enable or disable the dynamic rescaling code (default: 0). If enabled Pound will periodically try to modify the back-end priorities in order to equalise the response times from the various back-ends. This value can be overridden for specific services.

Pound is small, well documented, and easy to configure.

larsks