Deepak Singhal
Deepak Singhal

Reputation: 10864

Really solve "Too many open files" at a process level not on global ubuntu level

We have tomcat running and we face "Too many open files" problem intermittently.. We have really done lots of google and checked out all of stackoverflow and done everything to fix it like modifying "/etc/security/limits.conf" etc..

Now ulimit -n shows a higher number but still we keep facing problem.

Upvotes: 3

Views: 3335

Answers (2)

Jeff
Jeff

Reputation: 452

Under ubuntu 16.04 tomcat's maximum number of files is limited by systemd and set automatically to 4096. You can change this value by running

systemctl edit tomcat7

add the following lines:

[Service]
LimitNOFILE=8192

alternatively you can create the config by yourself:

mkdir /etc/systemd/system/tomcat7.service.d/
nano /etc/systemd/system/tomcat7.service.d/override.conf 

after that reload tomcat:

service tomcat7 restart

and double check that the limit is set correctly

ps ax | grep tomcat
cat /proc/<processId>/limits 

Upvotes: 2

Deepak Singhal
Deepak Singhal

Reputation: 10864

Finally when we tried $ cat /proc/<processId>/limits ; we noticed that "Number of open Files" was still shown as 4096 which is old value; though for root it was showing higher values.

Finally we could solve the problem by modifying /etc/default/tomcat7 [ or any other file respective to your process] and adding following lines:

ulimit -Hn 10000
ulimit -Sn 10000

No need of rebooting the system; just restart the process and then check /proc/processId/limits

Upvotes: 2

Related Questions