Increasing the number of file handles on Linux workstations

For best product performance, increase the number of file handles above the default setting of 1024 handles.

About this task

Important: Before you work with your product, increase the number of file handles. Most products use more than the default limit of 1024 file handles per process. A system administrator might need to make this change.

Exercise caution when using the following steps to increase your file descriptors on Linux. If the instructions are not followed correctly, the computer might not start correctly.

Procedure

To increase your file descriptors:

  1. Log in as root. If you do not have root access, you must obtain it before continuing.
  2. Change to the etc directory.
    Attention: If you decide to increase the number of file handles in the next step, do not leave an empty initscript file on your computer. If you do so, your computer will not start up the next time that you turn it on or restart.
  3. Use the vi editor to edit the initscript file in the etc directory. If this file does not exist, type vi initscript to create it.
  4. On the first line, type ulimit -n 30000. The point is that 30000 is significantly larger than 1024, the default value on most Linux computers.
    Important: Do not set the number of handles too high, because doing so can negatively impact system-wide performance.
  5. On the second line, type eval exec "$4".
  6. Save and close the file after making sure that you have completed steps 4 and 5.
    Note: Ensure that you follow the steps correctly. If this procedure is not completed correctly, your computer will not start.
  7. Optional: Restrict the number of handles available to users or groups by modifying the limits.conf file in the etc/security directory. Both SUSE Linux Enterprise Server (SLES) Version 9 and Red Hat Enterprise Linux Version 4.0 have this file by default. If you do not have this file, consider using a smaller number in step 4 in the previous procedure (for example, 2048). Do this so that most users have a reasonably low limit on the number of open files that are allowed per process. If you use a relatively low number in step 4, it is less important to do this. However, if you set a high number in step 4 earlier and you do not establish limits in the limits.conf file, computer performance can be significantly reduced.

    The following sample limits.conf file restricts all users, and then sets different limits for others afterwards. This sample assumes that you set handles to 8192 in step 4 earlier.

    *      soft nofile 1024
    *      hard nofile 2048
    root    soft nofile 4096
    root    hard nofile 8192
    user1   soft nofile 2048
    user1 hard nofile 2048

    Note that the * in the preceding example sets the limits for all users first. These limits are lower than the limits that follow. The root user has a higher number of allowable handles open, while the number that is available to user1 is between the two. Make sure that you read and understand the documentation that the limits.conf file contains before making changes.

What to do next

For more information on the ulimit command, see the main page for ulimit in the Linux documentation.