users@glassfish.java.net

Re: AW: "Too many open files" error in Linux

From: Mark Mielke <mark_at_mark.mielke.cc>
Date: Thu, 03 Jun 2010 09:47:39 -0400

Linux, like many other UNIX systems, defaults to a maximum of 1024 file
descriptors. For the most part, this is to provide compatibility with
"legacy" applications, although MANY applications fall into this category.

Any application that uses select() and "fd_set *", with the standard
macros FD_CLR(), FD_ISSET(), FD_SET(), and FD_ZERO(), is using an
interface that normally uses a predefined bitmask size of 1024. As only
1024 bits are allocated, then if the system returned a file descriptor
greater than 1024, then the program would start scribbling over memory
outside the bit mask and cause problems. Applications that uses poll()
or epoll are safe from this problem. Java is safe from this problem.

On my servers, I set the "hard" limit to 8192 and leave the "soft" limit
at 1024. This means that programs are restricted to 1024 unless they
specifically know how to raise the "soft" limit up to the "hard" limit
themselves. Java knows how to do this and does it automatically in my
experience.

On Fedora 11, I raise the "hard" limit using the following lines in
/etc/security/limits.d/99-max-files.conf:

* soft nofile 1024
* hard nofile 8192

You may need to logout and login for this to take effect. A full reboot
will ensure that all processes benefit from this change.

 From the command line, before starting Glassfish, you can execute the
following:

ulimit -Hn 8192

Note that "ulimit -Hn" probably requires root to run. Therefore, you
would have to run this command in startup scripts *before* switching to
become the Glassfish user. I prefer
/etc/security/limits.d/99-max-files.conf as this avoids the need for
wrapper startup scripts.

Cheers,
mark


On 06/03/2010 04:12 AM, Haluk Durmus wrote:
> Are you running glassfish on a virtual server ?
>
>
> ----- Ursprüngliche Mail ----
> Von: "glassfish_at_javadesktop.org"<glassfish_at_javadesktop.org>
> An: users_at_glassfish.dev.java.net
> Gesendet: Donnerstag, den 3. Juni 2010, 11:18:07 Uhr
> Betreff: "Too many open files" error in Linux
>
> My Glassfish works on Linux.
> I have 3 simultaneous domains.
>
> Often when I start domain it throws
>
>>> java.io.IOException: Too many open files
>>>
> What should I do to get rid of it ?
> [Message sent by forum member 'boraldo']
>
> http://forums.java.net/jive/thread.jspa?messageID=472515
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>
>


-- 
Mark Mielke<mark_at_mielke.cc>