[Mongrel] Mongrel error : EMFILE too many open files
wyhaines at gmail.com
Mon Dec 17 12:17:37 EST 2007
On Dec 17, 2007 10:05 AM, Scott Derrick <lists at ruby-forum.com> wrote:
> The reason why I think this is a mongrel reliability issue is that when
> my mongrel server stops responding, its stops responding to everybody!
> Any browser from any client machine that trys to access any page on the
> website gets "nada", no response..
> I can't even get a page not found 404 error if I feed it a bad address,
> the mongrel server is locked up and not responding, to anybody.
> Maybe I don't understand the linkage between my web app and the web
> server, I didn't think my application by running a periodic update could
> cause the server to refuse any new connections? Its not like its really
> busy with a couple hundred requests a second, its 5 requests a second,
> on a fast server?
Yeah. The standard Mongrel is multithreaded using Ruby green threads.
When a request comes in, a new ruby thread is created to handle that
request. This isn't true concurrency because all of the green threads
are handled inside the single process, but it lets Mongrel have
multiple things in-process at the same time, which is occasionally
useful (though not as big a deal as a lot of people seem to think,
Rails, however, is unsafe when there is more than one request
in-process at the same time. So the handler for Rails has a mutex in
it that locks the Rails processing to a single request at a time.
In addition, Mongrel is subject to the same limits on file descriptors
and open files that your app as a whole is.
My suspicion is that your Rails code is eventually deadlocking on an
exhausted open files limit, and when it does that, everything else is
blocked up and nothing moves anymore.
I don't do Rails, so I'm not going to be of much help in suggesting
solutions, but it sounds like something about how sessions are being
handled is leaving open filehandles laying around. That's why I
suggest taking the question to a Rails specific forum, where you can
probably find someone who knows the details about the session
management option that you are using, and can pinpoint the problem for
More information about the Mongrel-users