What is a safe ulimit ceiling?

Solution 1:

max-open is number of files one user can keep open in single session simultaneously.

Also, please note that all limit settings are set per login. They are not global, nor are they permanent; existing only for the duration of the session.

(from man limits.conf(5))

Safe value for maximum number of really depends on your usage. Point with default values is to prevent trivial (accidental) denial of services. There is also global limit for number of open files:

cat /proc/sys/fs/file-max

You can change that number by running for example

echo 100000 > /proc/sys/fs/file-max

(with user root, obviously). Even better is to also add line fs.file-max = 10000 to /etc/sysctl.conf to load same setting after reboot.


As of ulimit: it's safe to increase that number. However, number of open files should not exceed global file-max, because then opening new files is not possible anymore (and for example logging in requires opening files).

If there is multiple users, remember that if you change the default, everyone can open more files. For example 30 users * 5000 files = 150 000 open files (assuming that everyone opens maximum number of files, and uses only single session). If you have some really resource hungry (as in opens really many files) software used by multiple users, it might be a problem.