tags:

views:

34

answers:

3

Is there a limitation on the number of sockets being used in any application? In our application for record locking purpose we are handling all the connected users in a middle layer which sometimes get crashed when more number of users are connected to that.

+1  A: 

There is a limit of open files per process (that include sockets). You can check it by ulimit -n

a1ex07
+1  A: 

Yes, there is a soft and hard limit (at least on Unix) see the getrlimit() and setrlimit() calls to check.

Martin Beckett
+1  A: 

On linux, you can view the limits using ulimit -a:

core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 15347
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 10240
cpu time               (seconds, -t) unlimited
max user processes              (-u) 1024
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

As a1ex07 mentioned, the limit in this case is 1024, although it can be adjusted. This article has some more information on performance tuning that might be of interest.

Justin Ethier