I’ve been looking into deployment for a rails app for a week and I
have to say I’m totally overwhelmed by the options! The main problem
is I can’t use Apache 2.2, only 2.0.
I’m sold on mongrel and clustering with it. But what to use for a
balancer and static file server?
I’m messing with LightTPD, seems to be working but I just read on the
NGINX site that it leaks 20MB/hour? Yikes. Can’t have that.
NGINX looks promising, but what kind of support is there? Can I tell
our sys admins that it’s OK and nothing to worry about?
I don’t think I can do Apache because it doesn’t do load balancing on
2.0.
What should I do? The main concern is that whatever setup I choose, it
needs to be as light weight as possible and almost invisible to the
rest of the server in terms of strain.
Should we just let Mongrel serve static content and use Pound or
Balance?
Thanks for any help or recommendations. What I’d love to see (wishful
thinking) is a list of pros and cons of each valid setup.
There is always rewritemap-based proxying using a rnd: map to select
the port to proxy to. I use this with some sucess, admittedly on
relatively low-traffic sites. I’ll probably add in Pen if the use of
the map became an issue.
(I still need Apache’s rewrite rules because of another requirement
for rewrite maps, otherwise I’d probably be using nginx to deal with
static files as well.)
You could always use Pound in front as your load balancer, and then
direct
static files to Apache, and dynamic to a mongrel cluster. Part of this
depends on whether you can create the configuration in Pound so as to
determine the difference between static and dynamic files, so that you
don’t
have to do say the Apache rule of “does this file exist on disk, if so,
it’s
static, and serve that, if not, go to Mongrel.” But, in my experience,
I’ve
found Pound to be very easy to configure and use, and had good
performance.
I think Nginx is definitely worth a look, but if you require known
support
and things like that, then that will likely rule it out. I don’t have
enough experience with it to say how solid it is, I’ve mainly done
benchmarking against it (with good results there).
I’m in a similar situation. I’ve used both an apache->pen->mongrel
approach with a side of thttpd and, apache->nginx->mongrel. I’ve only
started using nginx in the last couple of weeks but, since I compiled it
in user space the system admins didn’t even know it was there until I
told them today. brainspl.at has a great config example that takes into
account rails page caching and Capistrano maintenance commands.
NGINX site that it leaks 20MB/hour? Yikes. Can’t have that.
Should we just let Mongrel serve static content and use Pound or
Balance?
Thanks for any help or recommendations. What I’d love to see (wishful
thinking) is a list of pros and cons of each valid setup.
Hi Matt,
Here is a way to combine Apache 2.0 with nginx
Put something like this in your virtual host replacing 3000 with the
port number that nginx is going to use. The line “ProxyPass /errors !”
prevents apache from requesting files from /errors from nginx instead of
serving them itself. Which is really useful if you want to have custom
error messages, and don’t want apache to say something like “error 503
bad gateway, additionally a 503 error was encountered trying to retrieve
the error document” when nginx isn’t running. You can use similar
syntax to have apache serve any content rather than ask nginx for it.
so you could drop a php webapp in /php, and then “ProxyPass /php !”.
I’m messing with LightTPD, seems to be working but I just read on the
rest of the server in terms of strain.
Just use nginx and mongrel cluster. It meets your requirements
better then any of the other mentioned options. I am running close to
300 instances of nginx in front of mongrel clusters and nginx has
been rock solid, uses basically no resources even under heavy load
and is basically the one part of my stack that I’ve never had a
problem with.
Nginx is rock solid and IMHO the absol;ute best front end for
mongrel cluster available today. Using pound or anythign esle in
between apache and mongrel is just adding complexity for no benefits.
Just use nginx, you won’t regret it.
Cheers-
– Ezra Z.
– Lead Rails Evangelist
– [email protected]
– Engine Y., Serious Rails Hosting
– (866) 518-YARD (9273)
Or try HAProxy/Perbal -> Lighty and Mongrel cluster. After playing
around with many deployment options, I find this to be the best for
me. If you use HAProxy, you can work around the rails single threaded
issue. Perbal can serve static files really fast.