[Mongrel] multi threaded theoretically useful?
erik.hetzner at ucop.edu
Sat Sep 8 18:19:28 EDT 2007
At Fri, 7 Sep 2007 15:34:49 -0700,
"Kirk Haines" <wyhaines at gmail.com> wrote:
> Maybe, but it's irrelevant. The MySQL/Pg/whatever drivers aren't
> written to be aware of Ruby internals.
It is my estimation that any application is going to have a lot of
places where a ruby thread context switch is possible.
> Ezra? His response simplified it. Of course there are situations
> where green threads improve performance. They can be quantified very
> simply, as I already have. When there are external latencies that are
> not blocking the entire process, green threads can capture those
> latencies and turn them into additional work. A sleep() call is such
> a latency. Any pure ruby code that stays in rubyland and doesn't go
> into an external extension is such a latency. A DB query that spends
> most of its time inside of some C library that is external to Ruby is
> not such a latency.
Here is what I am trying to get at.
(a) It is nonsense to say that because ruby threads are not ‘real’
they will never be as fast as ‘real’ threads or multiple processes. It
is dependent, as I take you to mean, on the balance of your code
between code from which context switching can happen & code from which
(b) *If* you have an application that is threadsafe, you ought to
*test* it with multiple threads before you discount the possibility
that you will be able to get *comparable* performance out of ruby’s
threading than you will from multiple processes, esp. because running
multiple threads rather than multiple processes provides some
It is my belief that in general with a threadsafe mongrel app you are
going to find that the best system is one that combines multiple
processes to take advantage of multiple cores & of preemptive
multitasking and multiple threads to take advantage of lower memory
consumption and the faster context switching which ruby should
Obviously everything depends on (a) your code, (b) your ruby
implementation, (c) your os’s scheduler, and (d) the phase of the
moon, which is why you ought to test to find out what works best.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/mongrel-users/attachments/20070908/310c053b/attachment.bin
More information about the Mongrel-users