You might need to increase the number of file descriptors from the default. A higher number of file descriptors ensures that the server can open sockets under high load and not abort requests coming in from clients. Start by checking system limits for file descriptors with this command:
cat /proc/sys/fs/file-max 8192 |
The current limit shown is 8192. To increase it to 65535, use the following command (as root):
echo "65535" > /proc/sys/fs/file-max
To make this value survive a system reboot, add it to /etc/sysctl.conf and specify the maximum number of open files permitted:
fs.file-max = 65535
The parameter is not proc.sys.fs.file-max, as you might expect.
To list the available parameters that can be modified using sysctl:
sysctl -a
To load new values from the sysctl.conf file:
sysctl -p /etc/sysctl.conf
To check and modify limits per shell, use the following command:
ulimit -a
The output will look something like this:
cputime unlimited filesize unlimit datasize unlimited stacksize 8192 kbytes coredumpsize 0 kbytes memoryuse unlimited descriptors 1024 memorylocked unlimited maxproc 8146 openfiles 1024 |
The open files and descriptors show a limit of 1024. To increase the limit to 65535 for all users, edit /etc/security/limits.conf as root, and modify or add the nofile setting (number of file) entries:
* soft nofile 65535 * hard nofile 65535 |
The asterisk (*) is a wildcard that identifies all users. You can also specify a user ID instead.