Linux : Increase maximum open file descriptors

By | January 31, 2012

On most heavy usage servers, you probably need to override the maximum open file descriptors in order to handle the load! Do not play with this setting blindly, make sure you know what you’re doing! In most case, you will be warned in log wit message like this : Too many open files

You may have a look at the current value using the following command :

cat /proc/sys/fs/file-max

To increase it right away without reboot the server simply type (replace the value according your needs) :

sysctl -w fs.file-max=100000

Okay, now you need to add it to sysctl in order to make your new setting permanent (the above command will actually not make the setting survive to reboot) :

vi /etc/sysctl.conf

And add :

fs.file-max = 100000

 

The above was to set the maximum file descriptor system wide. Setting it for specific user is not much difficult.

Edit :

/etc/security/limits.conf

And add :

user soft nofile 8192
user hard nofile 16384

(Replace “user” with the designated username and the number according your needs.)