Increasing the system limits

If you got this far, maybe you’re starting to feel let down. You’ve done everything right, but still your application is crashing. Don’t worry, it’s normal. Some applications just have to handle more files than what OS defaults are set. The rest of the guide is for specific for an Ubuntu stack.

ulimit

The system limits for open file descriptors are set in /etc/security/limits.conf. You can change those by editing the file or by running:

ulimit -Hn 65536
ulimit -Sn 65536

You can now check if the limits were applied to your play application by running:

for pid in `pidof java`; do echo "$(< /proc/$pid/cmdline)"; egrep 'files|Limit' /proc/$pid/limits; echo "Currently open files: $(ls -1 /proc/$pid/fd | wc -l)"; echo; done