24 Feb

slate is Served

February 24th, 2007 — 7:12 pm Dave

One of the really interesting things with Rails is the number of different methods for serving up content. Well, not terribly many but there is more to it then just Apache (nginx, anyone?). In the very early days of our development using Rails we focused on using Apache with FastCGI. This was mainly for projects like Typo when we first tried blogging. Definitely not a good fit… FastCGI would just zombie out. We had to have a scheduled task that would run through every few hours and kill Ruby processes to make sure they didn’t zombie (poor processes, killed before their time). Also a pain to set-up on Windows. So, overall… Apache + FastCGI was a dud. We had to find something else if we wanted to run slate without headaches.

Luckily along came a poor mutt. Mongrel quickly became the flavor of the month* for delivering Rails sites and we took note. The mongrel_service gem and some very nice Win32 documention clinched it for me. So we launched slate v0.1.0 at the end of May 2006 with Apache 2 handling static files and proxying to one Mongrel service. But now, instead of having a headache, I was getting twitchy… like nervous twitchy.

See, mongrel can only serve one request at a time. A one-to-one relationship… and we were only running one service. I’m a moron, see this blog post for why So for a while I was wondering what our performance would be (I still have yet to do an httperf). How slow would slate really be? Well, I needn’t have worried. slate and Mongrel were exceptionally fast. As Chris says, “Sometimes it feels like the page is served faster then it can be rendered.” And it seriously felt that way. So we’re happy for a few months. But, wait, we’re going to put a real asset manager in place with v0.3.0. People might be uploading/downloading big files. It made me wonder again… is one enough? twitch

Again, we might have gotten lucky. Apache 2.2 was released with mod_proxy_balancer. Ah, a method to run multiple Mongrels (the pack) and continue using the set-up we were happy with. So in December 2006 we went ahead and put Apache 2.2 in place with ten (10!) Mongrel services. Thinking, “Heck, if this flames out we’ll just go to 20!” About the only issue we had (well, Chris had) was coming up with a method to quickly start and stop the services as we don’t have access to Capistrano in our current environment. Initial reactions? slate felt a hair slower but I wasn’t twitchy anymore.

Fast forward a couple of months and my feeling now? Still digging it. Now we did run into a problem with Mongrel getting a little too big for it’s britches RAM-wise and making slate slow to a crawl. Of course it had to happen during a demo day but we now know to keep an eye on it. I wish we could use something like Monit but we’re stuck until we get new hardware. Do we need ten (10!) services? Probably not (only 3 page views per minute on average) and from what I’ve read it’s prolly a bad idea anyway. Luckily it’s not like we’re in a shared environment or anything and we have a whole box to ourselves for this project.

So now you know how slate is served :)

  • – it’s definitely moved beyond flavor of the month and it’s nice to see it’s going to be included in Mac OS X 10.5 Server
#1: Chas Grundy said on Feb 24 at 11:48 pm

Interestingly, just saw this article come through RailsTips.org. It's from Kyle Maxwell where he describes how Mongrel is multi-threaded, but that Rails is the single-threaded bottleneck. http://blog.kylemaxwell.com/2007/2/1/file-uploads-mongrel-and-rails It's worth knowing the subtleties, I suppose.

#2: John Nunemaker said on Feb 25 at 1:06 am

"See, mongrel can only serve one request at a time." Actually, it's not mongrel, it's rails that doesn't support concurrency. I haven't actually looked into why rails doesn't support concurrency yet but I will be soon. Here is a more in depth explanation: http://blog.kylemaxwell.com/2007/2/1/file-uploads-mongrel-and-rails

#3: Dave said on Feb 25 at 9:16 am

And now I look like a moron. At least it's a "popular misconception." I actually double-checked that before posting just in case and found a lot of talk about the "single threaded"-ness of Mongrel. Ah, well.

#4: John Nunemaker said on Feb 25 at 9:42 pm

I totally didn't know chas had posted a comment. I had left my browser open to read the post later and never refreshed to see if anyone commented. It is a really popular misconception. I just discovered the error of my ways a month ago.

#5: Dave Olsen said on Feb 26 at 9:20 am

We have to moderate all of the entries so I'm sure we'll get a lot of these type of "dupes." Just depends on when we check.

Add comment

You are adding a new comment