We recently got a "too many open files" error in our production Wildfly 17 on debian 9. A simple restart of the wildfly service got rid of the error but I'd like to avoid the problem to come back. I'd like to increase the limit but I'm not sure what I should change and how can i know the configuration as been taken into account.
I checked the ulimit for the loginless wildfly user :
sudo su - wildfly -c 'ulimit -a' -s '/bin/bash'
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 117724
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 117724
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
The limit seems to be set at 1024 for the user. However I can check the number of open files by my wildfly processes and I have this :
sudo ls -l /proc/PID/fd |wc -l
1296
Which is bigger than the limit and I'm not getting any error right now. Is there a way to set the limit higher permanently ? Maybe in the wildfly configuration files ? I'm a bit lost.
You need to edit/add records in
/etc/security/limits.conf
. For example one records for userwildfly
and number of open files may looks like:This set number of open files for the user to 16384
P.S. You should logout and then login (as user
wildfly
) to make this in workcat /proc/ 'pid' /limits | grep files will show you the value of the max open files specific for the wildfly process.
lsof -a -p 'pid' | wc -l will show the current number of open files for the specific pid