[Mongrel] mongrel limiting amount of connections ?

Piet Hadermann piet.hadermann at seagha.com
Thu Feb 8 06:59:53 EST 2007


Hi!
 
I've been using Mongrel in a Rails setup with HAProxy as a loadbalancer.
 
I used to use Pound, but HAProxy is much more performant and has the
very nice option to limit the amount of requests sent to the backend
servers/processes. In practice, this means that a new incoming request
will not be sent to a Mongrel that's already busy processing a request.
 
There's an exception to this wonderful world though. If a request takes
a long time to finish, either HAProxy can timeout, or the user presses
the 'stop' button or does a reload. This means that there's no way the
result of whatever that Rails process is doing at that time will make it
back to the user. Also, in this case HAProxy thinks the backend server
is ready to accept a new connection, which will only get queued up a
Mongrel level, causing yet another user to wait for ages or do a
stop/reload, leading to a possibe escalation of long running processes
and users waiting for responses.
 
Wouldn't it be possible to have an option where you kill the current
running thread (Rails process) when a new one gets accepted ? I believe
that's what the -n option was meant to do, still, this doesn't seem to
work 100% the way I'd except it to (which means nothing). In my
experiments, the long running request just continues until it's
finished.
 
Alternatively if mongrel wouldn't accept new requests when it's still
busy processing one, and the loadbalancer (HAProxy) would detect it
can't connect and try the next server, this would be a smaller step in
the right direction (I think).
 
I know you should just avoid long-running processes and let backgroundrb
handle them, which I do in several cases, but on one installation
there's so much data in the (oracle) database which is continuously
growing that if it decides to take an alternative path to resolving a
query this can have a disastrous impact on performance.
 
These are just my ideas, if anyone has a better solution or suggestions,
I'd really like to hear about them.
 
Piet.
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/mongrel-users/attachments/20070208/ed036001/attachment.html 


More information about the Mongrel-users mailing list