Centos running Apache Tomcat keep getting "java.net.SocketException: Too many open files"

Posted by Gerard Moroney on Server Fault See other posts from Server Fault or by Gerard Moroney
Published on 2014-05-29T06:31:01Z Indexed on 2014/05/29 9:30 UTC
Read the original article Hit count: 348

Filed under:
|
|
|

We're running Apache Tomcat 7.0.41 on CentOS 6 with java version "1.7.0_21". We were getting a lot of too many open files errors so I did some research. The consensus was that it was to to with the number of open files. So I did the following:

  • Increased max files in /etc/security/limits.conf

    soft     nofile         100000
    hard     nofile         100000
    
  • Rebooted the server

  • Checked the limits were valid for the user which was to run the process

    [app_admin@xxx ~]$ ulimit -Hn
    100000
    [app_admin@xxx ~]$ ulimit -Sn
    100000
    
  • Monitored open files on the server using the lsof command

What I observed was when the total open files reached circa 13000 and tomcat had around 4500 open files the error reappeared.

I am confused. I thought it would have resolved the problem but clearly I don't fully understand the root cause and also how to set the parameter correctly.

To (maybe) help I have not modified the server.xml file for Tomcat (although I'm tempted). I don't want to start fiddling with that and make things worse.

I'm more than happy to share any more information if someone can give me some hints on where to start looking.

© Server Fault or respective owner

Related posts about centos

Related posts about Performance