[Mongrel] What's mongrel doing when it's idle.

Zed A. Shaw zedshaw at zedshaw.com
Thu Apr 12 15:53:48 EDT 2007


On Thu, 12 Apr 2007 11:03:36 -0700 (PDT)
rm_mongrel at cheapcomplexdevices.com wrote:

> 
> A totally idle mongrel seems to wake up about once a second doing
> a little stuff like:
>    select(4, [3], [], [], {0, 999696})     = 0 (Timeout)
>    gettimeofday({1176400534, 112594}, NULL) = 0
>    select(4, [3], [], [], {0, 0})          = 0 (Timeout)
>    time(NULL)                              = 1176400534
>    time(NULL)                              = 1176400534
>    gettimeofday({1176400534, 113841}, NULL) = 0
>    gettimeofday({1176400534, 114138}, NULL) = 0
> over and over.
> 
> I realize it's not a big deal to do so little so infrequently; but 
> wondering why it wakes up to do anything at all.    Any reason
> whatever it's polling for can't just be added to the select()
> conditions?

Ruby uses select() to do it's IO processing and thread control, but
only after you start one thread.

Ruby doesn't put a timeout parameter into the select call unless
there's a thread sleeping.

If you have threads waiting for IO, and have someone running Mongrel
from the console, and you don't have a thread calling sleep once a
second, then...

CTRL-C won't exit the process on most systems.

So, most ruby code that uses threads throws in a bogus sleeping thread
that doesn't do much.

-- 
Zed A. Shaw, MUDCRAP-CE Master Black Belt Sifu
http://www.zedshaw.com/
http://www.awprofessional.com/title/0321483502 -- The Mongrel Book
http://mongrel.rubyforge.org/


More information about the Mongrel-users mailing list