[Mongrel] multi threaded theoretically useful?
ezmobius at gmail.com
Fri Sep 7 18:39:33 EDT 2007
On Sep 7, 2007, at 3:34 PM, Kirk Haines wrote:
> On 9/7/07, Erik Hetzner <erik.hetzner at ucop.edu> wrote:
>>> And when you are waiting on something like a database, you are doing
>>> it within the DB driver extension, so there are no context switches
>>> happening -- your green threads are blocked.
>> Surely it is possible to write a C extension for Ruby that allows
>> context switching from within it? This is outside my understanding of
>> Ruby threads.
> Maybe, but it's irrelevant. The MySQL/Pg/whatever drivers aren't
> written to be aware of Ruby internals.
>>> The reason you get more performance when multithreading is because
>>> of that sleep call. It is all happening inside of Ruby, so when
>>> running in a multithreaded context, when one thread goes to sleep,
>>> the others just get the execution cycles. It's artificial, though.
>>> Read Ruby web apps don't tend to have latencies like that. When they
>>> are waiting, they are waiting inside of things that block the entire
>>> Ruby process, and not just waiting for something that is blocking a
>>> single thread.
>> I know why we are getting greater performance, and again, I don't
>> think it's artificial. But, in any case, it was a demonstration,
>> mostly for the original responder, who claimed that you would never
>> get more performance from Ruby threads.
Yeah I actually said that you would never get more performance out of
one mongrel running 10 threads then you would with 10 mongrels
running one thread. Just to clarify ;)
More information about the Mongrel-users