Wildfly – Too Many Open Files Error on Debian

debianlinuxulimitwildfly

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.

Best Answer

You need to edit/add records in /etc/security/limits.conf. For example one records for user wildfly and number of open files may looks like:

wildfly  soft    nofile          16384
wildfly  hard    nofile          16384

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 work