Too many open files

cancel
Showing results for 
Search instead for 
Did you mean: 

Too many open files

resplin
Intermediate
0 2 10.3K

Obsolete Pages{{Obsolete}}

The official documentation is at: http://docs.alfresco.com



When you are running Alfresco in a UNIX environment you may be hit by the 'Too many open files' error. Symptoms that you may be affected is that when running the Share client some pages start displaying blank pages, or your dashlets fail to load. The issue manifests itself on *NIX systems where often the system is configured by default to allow users a maximum of only 1024 open file handles (eg. Ubuntu) which is often not sufficient for the alfresco.war and share.war applications.
The error is easily fixed by configuration changes in the operating system.


Verifying if you are affected


The error is not always logged in alfresco.log. You must also check the tomcat log in



tomcat/logs/catalina.out

and you may see something like



Feb 10, 2011 4:19:46 PM org.apache.tomcat.util.net.JIoEndpoint$Acceptor run
SEVERE: Socket accept failed
java.net.SocketException: Too many open files
  at java.net.PlainSocketImpl.socketAccept(Native Method)at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:390)
  at java.net.ServerSocket.implAccept(ServerSocket.java:453)
  at java.net.ServerSocket.accept(ServerSocket.java:421)
  at org.apache.tomcat.util.net.DefaultServerSocketFactory.acceptSocket(DefaultServerSocketFactory.java:61)
  at org.apache.tomcat.util.net.JIoEndpoint$Acceptor.run(JIoEndpoint.java:352)
  at java.lang.Thread.run(Thread.java:662)

The catalina.out file can be large, so a quick way to see if you have the error in you file is to run



cat tomcat/logs/catalina.out|grep -C 20 Too

File Handles


In *NIX environments the error 'Too many open files' in the Alfresco log files may occur on systems during periods of heavy use and therefore it is recommended that on production Alfresco systems the normal 'open files' handle limit is increased.


Share client


Even if you are running the Share client (share.war) on a separate server, you may see that this server is affected by the 'Too many open files' error. It is recommended that you increase the file limits on this server as well.


How to increase the number for file handles available?


Start by verifying the current limit settings on your system.
On Linux, the global setting for the maximum number of file handles is usually set in



/proc/sys/fs/file-max

Check that this is a large number.

As the user used to run alfresco, run:



ulimit -n

This will tell you how many file handles the current user can have open at any one time.
This should be around 4096 which has worked well for us.

You may also want to run this command when you tomcat server is started to verify that the setting has taken effect



for pid in `pidof java`; do echo '$(

This will tell you if the setting changes is in effect by displaying the actual process limits for the java process in /proc/<processid>/limits.


Configuration changes


You should also check that the pam config enables all the right stuff - which it most likely will.
In /etc/pam.d/system-auth you should see:



session     required      /lib/security/$ISA/pam_limits.so
session     required      /lib/security/$ISA/pam_unix.so

For an Ubuntu server this has to be explicitly set in /etc/pam.d/common-session, add the row



session required pam_limits.so



Assuming you are on Linux and running alfresco as the user 'alfresco', then, as the root user, edit /etc/security/limits.conf and add:



alfresco soft nofile 4096
alfresco hard nofile 65536

This will set the normal number of file handles available to the alfresco user to be 4096 - the soft limit. If this proves to be too few (which is unlikely), the alfresco user can assign themselves more file handles, up to the hard limit, using:



ulimit -n 8192

Tomcat on Ubuntu


Various threads on the Internet have reported that Tomcat may still ignore the updated ulimit setting. If you encounter this having followed the above advice you may find this blog post useful.

Troubleshooting

2 Comments