PingDirectory

Setting the file descriptor limit

About this task

The server allows for an unlimited number of connections by default but is restricted by the file descriptor limit on the operating system. If needed, increase the file descriptor limit on the operating system with the following procedure.

If the operating system relies on systemd, see the Linux operating system documentation for instructions on setting the file descriptor limit.

Steps

  1. Display the current hard limit of the system.

    The hard limit is the maximum server limit that can be set without tuning the kernel parameters in the proc filesystem.

    ulimit -aH
  2. Edit the /etc/sysctl.conf file.

    Choose from:

    • If the fs.file-max property is defined in the file, ensure the value is set to at least 65535.

    • If the line does not exist, add the following to the end of the file.

      fs.file-max = 65535
  3. Edit the /etc/security/limits.conf file.

    Choose from:

    • If the file has lines that set the soft and hard limits for the number of file descriptors, make sure the values are set to 65535.

    • If the lines are not present, add the following lines to the end of the file (before #End of file).

      * soft nofile 65535
      * hard nofile 65535

      Insert a tab between the columns.

  4. Reboot the system.

  5. Run the ulimit command to verify that the file descriptor limit is set to 65535.

    Example:

    ulimit -n

    After the operating system limit is set, you can configure the number of file descriptors that the server uses by either using a NUM_FILE_DESCRIPTORS environment variable, or by creating a config/num-file-descriptors file with a single line, such as NUM_FILE_ DESCRIPTORS=12345. If these are not set, the default of 65535 is used. This is strictly optional if you want to ensure that the server shuts down safely prior to reaching the file descriptor limit.

    For RedHat 7 or later, modify the 20.nproc.conf file to set both the open files and max user processes limits:

    /etc/security/limits.d/20-nproc.conf

    Add or edit the following lines if they do not already exist.

    * soft nproc 65535
    * soft nofile 65536
    * hard nproc 65536
    * hard nofile 65536
    root soft nproc unlimited