[IRCServices Coding] A bit more on FD limits (not strictly services-related)

Russell Garrett rg at tcslon.com
Wed Jun 5 04:39:02 PDT 2002


OK, I've done a touch more research on this, the Linux default is
maximum 1024 FDs per process, and 4096 in total. A `cat
/proc/sys/fs/file-nr` will tell you the number of open FDs, the
number in use, and the maximum limit.

To increase the maximum number of FDs to 65536 (for a 2.2 kernel - I
think 2.4 is the same):

1. In /usr/include/bits/types.h change the "#define __FD_SETZISE
1024" to "#define __FD_SETSIZE 65536"
2. Do the same in /usr/include/linux/posix_types.h
3. Recompile your kernel

The following steps need to be performed every time you start the
FD-hungry application, or in your init scripts:

4. echo "65536" > /proc/sys/fs/file_max
5. echo "196608" > /proc/sys/fs/inode_max
6. ulimit -HSn 65536

Russ Garrett
russ at garrett.co.uk
www.faereal.net