Last week tomcat log file report many error about "Too many open files" when it has high traffic. Some in catalina_log say
and here is from localhost_log
This is because too many file descriptors're opened by tomcat. File descriptor can be limited in both system level and shell level.
To check maximum number of fd in system type 'cat /proc/sys/fs/file-max'. In my case it is 65536(someone said it should set to 200000). Tomcat error when try to open socket number 272 so I think 65536 is ok for me for now. Anyway if u want to set it add 'fs.file-max = 200000' to /etc/sysctl.conf
next go check shell level 'ulimit -n' give me 1024. This is reasonable b'coz I have three servlet each need about 3-4 fds per request. So I change this limit by add
in file /etc/security/limits.conf
Note:
To get the total number of handles that are used by process xxx
2007-04-07 16:13:40 HttpProcessor[80][272] Starting background thread
2007-04-07 16:13:40 HttpConnector[80] accept:
java.net.SocketException: Too many open files
and here is from localhost_log
2007-04-07 16:13:40 StandardWrapperValve[myservlet]: Servlet.service() for servlet myservlet threw exception
java.io.FileNotFoundException: /home/log/mylog_070407.log (Too many open files)
This is because too many file descriptors're opened by tomcat. File descriptor can be limited in both system level and shell level.
To check maximum number of fd in system type 'cat /proc/sys/fs/file-max'. In my case it is 65536(someone said it should set to 200000). Tomcat error when try to open socket number 272 so I think 65536 is ok for me for now. Anyway if u want to set it add 'fs.file-max = 200000' to /etc/sysctl.conf
pnix@pnix-a7:~$ cat /proc/sys/fs/file-max
65536
next go check shell level 'ulimit -n' give me 1024. This is reasonable b'coz I have three servlet each need about 3-4 fds per request. So I change this limit by add
* soft nofile 2048
* hard nofile 2048
in file /etc/security/limits.conf
Note:
To get the total number of handles that are used by process xxx
lsof -p xxx|wc -l
Comments
I added large values just to be sure:
* soft nofile 65535
* hard nofile 65535
Great blog, I bookmarked it straight away.
* soft nofile 2048
* hard nofile 2048
to take pleace must the pc be restarted?
sysctl -p
Many many thanks. Thanks and only thanks. I was struggling last 2 days to solve this problem.
Thanks again.
Binod Suman
I do have the same kind of issue, But, looking for different type of solution.
I am looking for a script to start weblogic server, once * soft nofile 2048
* hard nofile 2048 is done. with passing the PID for each instance to lsof, weblogic put the pid # in the log directory.Please, help me with the Warper or any Script
"session required pam_limits.so"