Linux: global, per-user and per-process limits on number of file descriptors

I have a problem: I am trying to test a demo server designed to deal with LOTS of simultaneous connections. And my tests fail at a small number because of socket.error: (24, ‘Too many open files’). I need to make the system let my test program open lots of sockets.

What are the current limits?

  • To obtain the current system-wide maximum number of file-descriptors-per-process, use 'cat /proc/sys/fs/file-max' or 'sysctl -a | grep fs.file-max'.
  • There is also a limit on how many file-descriptors a user may create: 'ulimit -n'

First we shall increase the system-wide limit: edit /etc/sysctl.conf and set the value of fs.file-max to the desired maximum. Run sysctl -p to effect the changes.

Now, let’s increase per-user limits. Edit /etc/security/limits.conf and put something like this at the bottom:

parijat hard nofile 400000

where ‘parijat’ is my login on this system. Logout and login again. ulimit -n should print 400000 now.

Post a comment or leave a trackback: Trackback URL.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: