Anyone who is on a small VPS (256mb in my case) knows how resources can run low pretty quickly! Especially if you are trying to run both a Rails site and a PHP site on it. Pretty much any stack you chose (whether it is nginx with mongrel, or lighttpd with fastcgi or mongrel etc..) uses a considerable amount of memory. Add MySQL to the mix (and most likely a mail server, maybe an ftp too, etc) and you are pretty much at 100% capacity…and your site doesn’t even have any traffic yet…
After trying a bunch of different setup, I can say that for me, LiteSpeed is the winner. Of course no matter which stack you chose, the way you optimize it will always make a big difference. For me, nginx with 1 worker process, 2 mongrel process (using mongrel_cluster) and 1 fcgi process for PHP was using almost 200mb of RAM (with mysql running). Both my rails app and my php site were extremely fast and snappy, even considering the low amount of worker process and mongrel instances. But then again, I had really really low traffic on the sites. Each mongrel process was taking approximately 30mb of memory.
The same sites (1 small rails app, 1 php site) on Litespeed was using approximately 150mb of RAM (approx. 50 less than nginx+mongrel_cluster). The ruby processes uses on average 15mb (instead of 30mb for the mongrel process). The performance seems just fine (although I had a feeling the sites were even faster with nginx, but this isn’t based on any benchmarks, just my personal feeling).
I’ll stick with the Litespeed setup for now until I can find something that uses even less memory.
For a great guide on how to setup Litespeed to serve both PHP and Rails site on Ubuntu, check out the articles at Usefuljaja.
For a great guide on how to setup nginx to serve both PHP and Rails on Ubuntu, check out the tutorial at UrbanPuddle.
If anyone has any suggestion for further optimization I’ll be glad to hear it!
One Comment
4gldrai1fj7y7j0h