[Mongrel] mongrel and long lived connections

Luis Lavena luislavena at gmail.com
Tue Dec 5 15:52:37 EST 2006


On 12/5/06, Joseph McDonald <superjoe at gmail.com> wrote:
> Hi,
>
> I found this article
> http://cyll.org/blog/tech/2006-08-09-themongrelcomet.html on mongrel
> and COMET very interesting.
>
> I ran the code, and it worked just as Christopher explained.  The one
> thing I don't understand is why mongrel can only handle 1 connection
> at a time.  I thought that mongrel used a thread per connection.
>

Let me correct you on this:

Mongrel CAN handle multiple incoming connections, Rails can't. Rails
is not thread-safe, mongrel is.

So: using mongrel with rails (ala, mongrel_rails command line util)
will put a lock around Rails dispatcher to avoid issues with
ActiveRecord.

> It appears that each registered handler can only handle 1 connection.
> So if a request comes into another handler, it will be handled.
>

Thats RailsHandler, other frameworks (AFAIK, IOWA, MERB) are thread
safe in that aspect.

> My question is:  Is there a way to allow a single handler to serve
> multple connections?
>
> I'm going to try debugging this to see why the handler is blocked, but
> if someone knows the answer before I find out, please shout it out.
>

Besides issue with the use of select() by ruby, also the use of
green(ala fake) threads instead of native ones... guess there is not
much help on this area.


Please, If I'm wrong in some of the things I have said, don't start a
flamewar, just point me in the right direction and correct my
ignorance :-)

-- 
Luis Lavena
Multimedia systems
-
Leaders are made, they are not born. They are made by hard effort,
which is the price which all of us must pay to achieve any goal that
is worthwhile.
Vince Lombardi


More information about the Mongrel-users mailing list