The Artima Developer Community
Sponsored Link

Python Buzz Forum
Is there such a thing as a preforking Rails server?

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Phillip Pearson

Posts: 1083
Nickname: myelin
Registered: Aug, 2003

Phillip Pearson is a Python hacker from New Zealand
Is there such a thing as a preforking Rails server? Posted: Sep 3, 2007 2:49 AM
Reply to this message Reply

This post originated from an RSS feed registered with Python Buzz by Phillip Pearson.
Original Post: Is there such a thing as a preforking Rails server?
Feed Title: Second p0st
Feed URL: http://www.myelin.co.nz/post/rss.xml
Feed Description: Tech notes and web hackery from the guy that brought you bzero, Python Community Server, the Blogging Ecosystem and the Internet Topic Exchange
Latest Python Buzz Posts
Latest Python Buzz Posts by Phillip Pearson
Latest Posts From Second p0st

Advertisement

It sounds like everyone's using Mongrel clusters in production for Rails apps these days, with one mongrel per CPU (see Alexey Koyvrin benchmarks for a bunch of typical configurations), but this seems a little limiting to me. If your controllers aren't optimized to suck 100% CPU all the time, your CPUs will be underused. It basically means you can't do any web service calls while servicing a request, or you'll block other clients.

IMHO Apache gets it right - "preforking" a bunch of processes, which are then used to serve requests. If a lot of requests come in, it forks off a few more processes to handle then, then reaps them as the load dies down. This means it can handle many simultaneous connections, without reserving much more memory than necessary. [ Of course, this usually means that your system will die when you get lots of connections unless you've set MaxClients conservatively, but at least you'll have some spare RAM for the disk cache when load is light ;-) ]

Hongli Lai has written a script to prefork a bunch of Rails processes, and has a good analysis of the other point of preforking: your server processes get to share memory, which can be fairly significant in the case of an interpreter running something with a decent sized library.

However, he found out a couple of months later that Ruby's garbage collector marks all pages as dirty, which breaks copy-on-write (as each child process will end up copying everything eventually, whether modified or not), then it wasn't particularly easy to fix that problem. He's since done a lot of hacking on Ruby's allocator/GC and it seems like things are moving along nicely. Looking forward to seeing the next post in the series.

Anyway, back to the original point -- where's the flexible preforking server for Rails? Is that what you end up with if you use FastCGI under Apache? Or does the (apparently quite large) memory footprint of a set of Mongrel/Rails processes make it prohibitively expensive to run more than four at a time?

Along those lines, TextDrive suggests that RAM usage of 30MB per FastCGI dispatcher is typical, and it can get up to 70MB+ if you use RMagick. MethodMissing.com (Lourens Naude) suggests more like 100-130MB.

Comment

Read: Is there such a thing as a preforking Rails server?

Topic: First python 3.0 try ! Previous Topic   Next Topic Topic: Grok, Zope3 and the Pink Panther's dream house

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use