The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Web Server and Configuration

I'm just starting to explore Ruby and RoR. I installed them on my local computer (Windows) the other day, and so have been reading why’s (poignant) guide to ruby as an introduction to Ruby.

Anyway, I'm really thinking of trying to develop in it for a personal project I want to work on. I installed ruby already on my server for something else, so just had to compile rubygems, and then install rails.

But now I'm wondering which web server it's going to be best with. Well, I'm not really sure if I have a choice since I already have Apache running with SVN and such. But if I did, what would you say is the best option as far as configuration and an actual web server are concerned?

Mongrel is fine if you aren't hosting a busy site. Great for development and intranets.

If you need more power, Apache is an obvious way to go though servers like Lightpd are faster. The great thing is that you don't have to use FastCGI any more (setting that up was always the hardest part of getting a Rails app up and live). Apache mod_proxy is all you need nowadays.

Mongrel is fine if you aren't hosting a busy site. Great for development and intranets.

If you need more power, Apache is an obvious way to go though servers like Lightpd ar'e faster. The great thing is that you don't have to use FastCGI any more (setting that up was always the hardest part of getting a Rails app up and live). Apache mod_proxy is all you need nowadays.

Interesting. I'm strongly considering going with lighttpd, though I'm not sure yet and need to explore all of the limitations first.

One thing is I'm running SVN under Apache right now, though admittedly I'm thinking also of switching over to git. I also currently have Trac running under Apache and am not sure whether it would run under lighttpd or not.

Also I will probably host other projects from clients there, and I hear lighttpd doesn't support htaccess, which might be a problem. I'm not sure, though, because it still seems to support mod_rewrite, and I obviously have control over whatever equivalent to httpd.conf it has, so could probably just include them in there.

I don't trust apache with fastCGI; too many troubles. Perhaps they've finally fixed them, but apache/fastCGI was a problem child from the beginning, partly why so many other options were born.

Staying with apache, there are a couple of choices. Easiest choice is to slide into apache and Passenger. From the coding side, passenger works just like mod_php does with PHP code. I don't think I'd use this for a heavy-traffic site, but should be fine for lower sites.

Another option is to use apache as a load-leveling proxy for a group of mongrel servers. apache passes the requests, keeps the load balanced, and the mongrels run the ruby code. Harder to set up, but is better suited for heavy lifting.

After that, your best options are to leave apache. One that hasn't been mentioned yet is NgineX.

Also, as the Rails/merb merger goes ahead this year, lots of performance metrics will chance. One of the major bottlenecks in Rails speed is ActiveRecord, and the merger will render that optional, instead of mandatory, in Rails.

Personally, I use mongrel locally for development, and most of my production sites use Passenger, as they so far haven't grown enough to hit the wall there. And maybe as they do, Passenger itself will move the wall.

I'm a firm believer in not making decisions before they have to be made, which is why I've followed the path I did. Passenger makes deployment dead simple, and when capacity issues get closer and I have to decide on high-performance, I will.

I just found out about Passenger about 20 minutes before you posted, and already have it up and running , which says something for its ease of setup.

I am concerned that you say it can't handle a heavy traffic site that well, but I guess i don't have to worry about that yet. I'm making a site that I expect to be popular, since there is nothing of the sort like it yet.

While I know what I'm doing around the server, I'm not sure if I'm good enough to set up many Mongrel instances behind Apache, or even how that'd work, so hopefully the need for that is a long time off, or that Passenger can support heavier sites better before that time comes.

That's too bad ActiveRecord is the slowest, when it also sounds one of the most attractive parts of Rails. Oh well, we'll see how it goes, I guess.

I am concerned that you say it can't handle a heavy traffic site that well, but I guess i don't have to worry about that yet. I'm making a site that I expect to be popular, since there is nothing of the sort like it yet.

It all depends on the meaning of the word "heavy." If your traffic flow is going to rival facebook or twitter, I'm pretty sure Passenger will be your bottleneck. But there's a lot of configuration options inside of Passenger that you can use to help throughput, and if the traffic gets high enough, you can always choose hardware over software, and toss more servers into the fray.

That having been said, it seems the Phusion folks are living up to one of my expectations, at least; performance is rising (The Ruby Enterprise Edition pages say it outperforms litespeed, for example).

Oh, and the best news for Rails junkies is the huge speed boost coming with Ruby 1.9 -- true, it'll take the Rails community a while to catch up as finally fixing the broken Ruby thread model is as expected breaking a whole lot of other things. As this shakes out, your upper performance limit will be raised yet again. (But don't be in too much of a hurry. IIRC, the current release version of Passenger, 2.0.6, was one of the things Ruby 1.9 broke. The fix is in the git master tree, but it's not in a release version, yet.)