5 ms·
Nginx runs all my Rails sites and will forever. If you haven't tried it yet, I can't say enough good things about it. It never breaks. It has just absurdly g
by patio11 17y ago
Nginx runs all my Rails sites and will forever. If you haven't tried it yet, I can't say enough good things about it. It never breaks. It has just absurdly good memory consumption, which is clutch when you're trying to run your site on a memory heavy platform like Rails on a VPS which is very memory constrained.
(By comparison, Apache is quite the memory hog and I still haven't figured out how to say the magic words to get it to not effectively crash my blog and every other site on the server if I burst to 10,000 visitors in an hour. That is not supposed to be a big number. Apache has 500 MB to play with and still can't keep up.)
I also find, and this might just be a matter of taste, that the configuration makes more sense to me than Apache configuration does. This is funny because Apache configuration is obsessively well-documented and Nginx configuration is not.
Additionally, some easy-to-use features cover weak points in typical Rails (&etc) deployment scenarios. The big one for me is file serving, since my website is essentially one big PDF printing press. The simplest level (works for me, won't work for Facebook) is just having the file anywhere accessible on the disk and having the application put a special header on the response saying "Hey, Nginx: give them this path.", then terminating Rails' involvement. That frees up your Mongrel to start doing hard work again and greatly, greatly, GREATLY decreases the resources you need to stream your 5 MB PDF, 20 MB executable, etc to the user.
So it scales down, but does it scale up? Ooooooooh yeah. Impressively so. See the tales of Wordpress deployment, where not a whole lot of Nginx gets hit with a year's worth of my traffic every couple of seconds and still keeps on trucking.
- callmeed 17y agoSo, is your preferred config still nginx + mongrels? Have you experimented with nginx + passenger or nginx + unicorn?
- patio11 17y agoI experimented with Nginx + passenger and had little success in the time I had budgeted that weekend (almost certainly due to my own failings). That is my max geekout budget. After that I have to have a reason to rip out stuff and I've got no compelling reason to rip out Mongrel (nota bene: I typically deploy only one or two Rails applications per VPS, with the expectation that they'll essentially monopolize resource usage. If my deployments resembled that of a shared host who could have ~600 forgotten Build A Blog In 15 Minutes apps sitting around waiting for someone to access them again, I'd have figured out Passenger by now or paid someone to figure it out for me.)
- swombat 17y agoI found the main benefit of Passenger in a single-app setting is (much) easier initial setup. Give it a try next time you set up a server. It'll save you about 30 minutes to an hour of screwing around with mongrel cluster configs and nginx proxying.
- steveklabnik 17y agoHow long ago did you try it? I think I started using passenger in the past....3 months? The version of install-passenger-nginx-module I used would compile your nginx for you, and set up the configuration. You just have to change the path to your public directory.
- tptacek 17y agoPassenger is worth figuring out, especially if you plan to do more Rack apps in the future. Forget the performance. It's easier to set up (at least, the second time) and it's easier to manage.
- trevorturk 17y agoI've been using passenger + nginx very happily for a few months now. I'd highly recommend giving it another shot.
- cheald 17y agoI use nginx+passenger and love the heck out of it. Trivial to set up, blazing fast, rock solid, and easy to administrate. I've switched away from Apache for everything except my dev server, and haven't looked back.
- steve19 17y agothis sums up my experience with nginx. I have fallen in love with it :)
- dmillar 17y agoI'm wondering how often you have to restart your Mongrel processes? Seems Mongrel loves to bloat.
- silvestrov 17y agoYou can upgrade the nginx binary while in flight. I've put the last 2 upgrades online in that manner. See http://pastebin.com/32UX6UQ2 http://pastebin.com/32UX6UQ2 for howto.
- FooBarWidget 17y agoI thought Apache can also reload the configuration without dropping connections via graceful restarts?
- silvestrov 17y agoouch, I didn't know that one. Only plain restart.
- kordless 17y agoLoad balancers FTW.
- olliesaunders 17y agoYeah, silvestrov is talking about "upgrading the binary" here.