[Mongrel] Mongrel error : EMFILE too many open files

Scott Derrick lists at ruby-forum.com
Mon Dec 17 12:30:39 EST 2007

Kirk Haines wrote:

All that makes sense if

1.) sessions is the problem.  I upped the file handle limit to 4096 and 
now I don't get an EMFILE error from mongrel, mongrel just stops 
responding to requests...

2.) Mongrel and my Rails app share the same file handle limit?  I 
thought they were separate ruby apps?  Or do all Ruby apps share the 
same environment?

I've run mongrel with the -D flag and nothing in the log file.

other apps on the system are running fine so its certainly not a system 
wide   problem.

I have posted this problem on multiple Ruby and Rails forums, no luck in 
an answer so far.  I'm going to remove and reinstall ruby, gems and 
rails to see if  the multiple updates over the last 6 months have left 
some cruft that is causing the problem.

> On Dec 17, 2007 10:05 AM, Scott Derrick <lists at ruby-forum.com> wrote:
>> 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,
> though).
> 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
> you.
> Kirk Haines

Posted via http://www.ruby-forum.com/.

More information about the Mongrel-users mailing list