From dd6d5168e4f3dcb4555264265a05e5b61273893d Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 22 Mar 2011 17:22:00 +0000 Subject: thread_pool+thread_spawn: update documentation They're not bad with slow clients a previously thought. --- Documentation/comparison.haml | 4 ++-- lib/rainbows/thread_pool.rb | 27 ++++++++++++--------------- lib/rainbows/thread_spawn.rb | 21 +++++++++++---------- 3 files changed, 25 insertions(+), 27 deletions(-) diff --git a/Documentation/comparison.haml b/Documentation/comparison.haml index 2b3362a..6a8f126 100644 --- a/Documentation/comparison.haml +++ b/Documentation/comparison.haml @@ -33,7 +33,7 @@ %td.r18 Yes %td.r19 Yes %td.rbx Yes - %td.slow OK + %td.slow Yes %tr.comp_row %td.mod Coolio %td.tee No @@ -47,7 +47,7 @@ %td.r18 Yes %td.r19 Yes %td.rbx Yes - %td.slow OK + %td.slow Yes %tr.comp_row %td.mod EventMachine %td.tee No diff --git a/lib/rainbows/thread_pool.rb b/lib/rainbows/thread_pool.rb index 8f2b629..b7860eb 100644 --- a/lib/rainbows/thread_pool.rb +++ b/lib/rainbows/thread_pool.rb @@ -1,24 +1,21 @@ # -*- encoding: binary -*- # Implements a worker thread pool model. This is suited for platforms -# like Ruby 1.9, where the cost of dynamically spawning a new thread -# for every new client connection is higher than with the ThreadSpawn -# model. +# like Ruby 1.9, where the cost of dynamically spawning a new thread for +# every new client connection is higher than with the ThreadSpawn model, +# but the cost of an idle thread is low (e.g. NPTL under Linux). # -# This model should provide a high level of compatibility with all -# Ruby implementations, and most libraries and applications. -# Applications running under this model should be thread-safe -# but not necessarily reentrant. +# This model should provide a high level of compatibility with all Ruby +# implementations, and most libraries and applications. Applications +# running under this model should be thread-safe but not necessarily +# reentrant. # -# Applications using this model are required to be thread-safe. -# Threads are never spawned dynamically under this model. If you're -# connecting to external services and need to perform DNS lookups, -# consider using the "resolv-replace" library which replaces parts of -# the core Socket package with concurrent DNS lookup capabilities. +# Applications using this model are required to be thread-safe. Threads +# are never spawned dynamically under this model. # -# This model probably less suited for many slow clients than the -# others and thus a lower +worker_connections+ setting is recommended. - +# If you're using green threads (MRI 1.8) and need to perform DNS lookups, +# consider using the "resolv-replace" library which replaces parts of the +# core Socket package with concurrent DNS lookup capabilities. module Rainbows::ThreadPool include Rainbows::Base diff --git a/lib/rainbows/thread_spawn.rb b/lib/rainbows/thread_spawn.rb index 30e143e..b304688 100644 --- a/lib/rainbows/thread_spawn.rb +++ b/lib/rainbows/thread_spawn.rb @@ -2,18 +2,19 @@ require 'thread' # Spawns a new thread for every client connection we accept(). This -# model is recommended for platforms like Ruby 1.8 where spawning new -# threads is inexpensive. +# model is recommended for platforms like Ruby (MRI) 1.8 where spawning +# new threads is inexpensive, but still seems to work well enough with +# good native threading implementations such as NPTL under Linux on +# Ruby (MRI/YARV) 1.9 # -# This model should provide a high level of compatibility with all -# Ruby implementations, and most libraries and applications. -# Applications running under this model should be thread-safe -# but not necessarily reentrant. +# This model should provide a high level of compatibility with all Ruby +# implementations, and most libraries and applications. Applications +# running under this model should be thread-safe but not necessarily +# reentrant. # -# If you're connecting to external services and need to perform DNS -# lookups, consider using the "resolv-replace" library which replaces -# parts of the core Socket package with concurrent DNS lookup -# capabilities +# If you're using green threads (MRI 1.8) and need to perform DNS lookups, +# consider using the "resolv-replace" library which replaces parts of the +# core Socket package with concurrent DNS lookup capabilities. module Rainbows::ThreadSpawn include Rainbows::Base -- cgit v1.2.3-24-ge0c7