Pages

Thursday, November 11, 2010

Solution for "Too Many Open Files" Issue

Here is a real practical solution for an issue faced in software development. The solution is given for linux users (Here it was tested in Cent OS 5).

Usually "Too many open files" Exception is thrown when we deploy many applications in a single server or in managed servers. The exception should be fixed in the OS level as there is no way to fix it in application level.
First get the system wide open files limit by using the following command.


vi /proc/sys/fs/file-max

This will show the current limit and the user can change it accordingly. (Log in as the super user) Please make sure to give a less value than the system memory.

Next, we need to sign the above value to a particular user. (Assign to the user name)
Open the limits.conf file and set the value as shown below.

vi /etc/security/limits.conf

There you can see the user level settings for the open file limits. Add the following two lines for the selected user. (Log in as the super user)

testuser soft nofile 755555
testuser hard nofile 755555

(Here, testuser is the user name and assumed the system has maximum memory of 8GB)

There you go, the problem solved as the open files limit is increased to a particular user.....

Remember, this won't cause any performance hits in the system.....

0 comments:

Post a Comment