Max file descriptors

In the same way that we have a maximum open file limit for sessions and processes, the kernel itself has a limit for the maximum open file descriptors across the whole system. If this limit is reached, no other files will be able to be opened, and thus this needs tweaking on machines that may have a large number of files open at any one time.

This value is part of the kernel parameters and as such can be seen with sysctl:

$ sysctl fs.file-max
fs.file-max = 757778

While on this machine the value seems reasonable, I have seen a few older distributions with a surprisingly low value that will get easily hit with errors if you are running a number of containers on the system.

Most kernel configuration settings we discuss here and later in this chapter can be temporarily changed with sysctl -w <key>="<value>". However, since those values are reset back to defaults on each reboot, they usually are of no long-term use for us and are not going to be covered here, but keep in mind that you can use such techniques if you need to debug a live system or apply a temporary time-sensitive fix.

To change this to a value that will persist across reboots, we will need to add the following to the /etc/sysctl.d folder (that is,  /etc/sysctl.d/10-file-descriptors-increase.conf):

fs.file-max = 1000000

After this change, reboot, and you should now be able to open up to 1 million file handles on the machine!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.163.142