7

This is the output of ulimit -a

core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 16382
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) unlimited
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

This is a 64bit install, and I would like to increase the max-open files from 1024 to a more heady limit such as 5000. Will that be any problem? Will it cause instability?

Thanks.

1 Answer 1

4

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.

1
  • What ulimit and file-max value would you advise for a single WebSocket server running on a single server? The default is 1024 on Linux, but I really feel that it is a very low value. Could you safely increase it to e.g. 200000 without experiencing any bottlenecks? Thank you! Oct 16, 2020 at 19:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .