rails 2 and slow external services

Eric Wong normalperson at yhbt.net
Mon Dec 13 23:57:20 EST 2010

ghazel at gmail.com wrote:
> > ghazel at gmail.com wrote:
> >> Some of my page loads (currently serviced by Unicorn) spend a great
> >> deal of time waiting for external services (OpenID, OAuth, etc over
> >> Net::HTTP and curb), so I'm looking at Rainbows!. I use Rails 2.3.10.
> This is Ruby 1.8.7 (REE). Is there any interesting difference between
> ThreadPool and ThreadSpawn in this environment?

ThreadPool is generally more predictable, but ThreadSpawn has lower
memory usage if your traffic spikes are intermittent or low.

ThreadSpawn is much like the original Mongrel and ThreadPool was an
experiment with Ruby 1.9 in mind.  1.9 has more expensive (but slightly
more concurrent) threading.  If your bottlenecks are external HTTP
requests on 1.8, but first instinct would be to use ThreadSpawn.

Ruby 1.9 + ThreadPool would probably be well-suited for large file
serving to LAN clients with many slowish disks as it can use sendfile
via IO.copy_stream), but if you can afford the constant memory overhead,
it could be good in 1.8, too.

> I also make use of a (heavily modified, which is another topic) OobGC.
> Does anyone know if garbage collection in ruby 1.8.7 is reasonably
> threadable? I expect not, but one can hope.

It is not, the entire interpreter stops running every single thread for
GC.  I don't think using OobGC with any of the Rainbows! concurrency
models will work, only :Base and Unicorn.

Eric Wong

More information about the rainbows-talk mailing list