Upper bound on no. of sockets
brbarret at osl.iu.edu
Thu Oct 2 13:05:54 EDT 2003
On Oct 1, 2003, at 6:59 AM, John Brookes wrote:
> I think there is a 1k per-process limit on open sockets. It's tuneable
> 2.4 kernels, IIRC, but I don't remember how (off the top of my head).
> 'ulimit -n' adjusts the max number of fd's, but I'm not sure that'll
> take it
> past a/the kernel limit. Maybe recompile kernel? Maybe poke
> /proc/sys/.../...? Maybe adjust in userland?
> Maybe use fewer sockets ;-)
> Does anybody know the score?
On linux, there is a default per-process limit of 1024 (hard and soft
limits) file descriptors. You can see the per-process limit by running
limit (csh/tcsh) or ulimit -n (sh). There is also a limit on the total
number of file descriptors that the system can have open, which you can
find by looking at /proc/sys/fs/file-max. On my home machine, the max
file descriptor count is around 104K (the default), so that probably
isn't a worry for you.
There is the concept of a soft and hard limit for file descriptors.
The soft limit is the "default limit", which is generally set to
somewhere above the needs of most applications. The soft limit can be
increased by a normal user application up to the hard limit. As I said
before, the defaults for the soft and hard limits on modern linux
machines are the same, at 1024. You can adjust either limit by adding
the appropriate lines in /etc/security/limits.conf (at least, that
seems to be the file on both Red Hat and Debian). In theory, you could
set the limit up to file-max, but that probably isn't a good idea. You
really don't want to run your system out of file descriptors.
There is one other concern you might want to think about. If you ever
use any of the created file descriptors in a call to select(), you have
to ensure all the select()ed file descriptors fit in an FD_SET. On
Linux, the size of an FD_SET is hard-coded at 1024 (on most of the
BSDs, Solaris, and Mac OS X, it can be altered at application compile
time). So you may not want to ever set the soft limit above 1024.
Some applications may expect that any file descriptor that was
successfully created can be put into an FD_SET. If this isn't the
case, well, life could get interesting.
Hope this helps,
Beowulf mailing list, Beowulf at beowulf.org
To change your subscription (digest mode or unsubscribe) visit http://www.beowulf.org/mailman/listinfo/beowulf
More information about the Beowulf