On Tue, 14 Aug 2007, Jano Svitok wrote:

> I suppose the main problem is that Rails (or ActiveRecord, I don't
> know exactly) is not thread-safe. That means you cannot share most of
> its the data. That is the reason why you have to run more mongrels
> compared to a one multi-threaded mongrel.

This is not the issue, really, when talking about issues of throughput 
with Ruby.  Only in uncommon cases will a multithreaded Ruby program 
actually deliver greater processing throughput than a single threaded Ruby 
program.  Basically, you have to have external latencies that can be 
captured _without_ your code waiting on those latencies inside of an 
extension.

If you run Rails (or some other web framework app) in a multithreaded 
mode, then yes, more than one request can be inside of the code, being 
handled at the same time.  The handling of each of those requests will be 
substantially slower, though, than if a process handles a single request 
at a time.  It may be a win with regard to app behavior, if there are fast 
actions in the same app with very slow actions, and one only wants to run 
a single, or a very small number of processing nodes (mongrels), because 
it lets the fast actions run to completion without requring them to wait 
on the slow actions.  But from the POV of overall throughput, it is not a 
win.


Kirk Haines