[Mongrel] Shared listening sockets
rob at robmela.com
Wed Oct 24 22:17:43 EDT 2007
Steve Midgley wrote:
> I thought I'd chime in as a Windows developer. I'm running Windows in
> development mode and deploying to Linux (Ezra's rig at EngineYard
> If this idea actually works, it's super appealing for me as a simple
> solution to the "slow returning mongrel" load balancing challenge.
> (i.e. the problems where mongrels are loaded up with requests
> irrespective of their availability, leaving some mongrels idle and some
I found out why it works on Linux 2.6.20. In net/ipv4/tcp_ipv4.c
accept is mapped to inet_csk_accept in net/ipv4/inet_connection_sock.c.
That csk accept calls inet_csk_wait_for_connect to wait for a
connection. That wait for connect function locks the socket so that if
multiple processes are calling accept() on that socket, only one process
at a time will be awaken when a connection request arrives.
This wil require some change in Mongrel's request loop. Mongrel
currently reenters accept even if it's got a worker locking Rails. If
Mongrels in the pool are calling accept while still locking Rals then
we're right back to square one, request queing. Mongrel would need to
either poll for worker list length == 0 before calling accept, or have a
"single-worker" mode in which it joins a worker thread as soon as it's
started, and only calls accept() after returning from that join.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 116 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/mongrel-users/attachments/20071024/489dfca1/attachment.vcf
More information about the Mongrel-users