# concurrent TCP/IP connections?

This topic is 4833 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi, Does anyone know if there are limits on the number of simultaneous open TCP/IP connections for say a system running RH 9.0? I know about there is this listen argument (default to 5?) that limits the no. of pending connections a system can take but is there also a limit once the connection is established? If so is what does it depend upon and if there is any ball park figure on how much? I'm writing a client-server app with the client running on windows and server on Linux (RH 9.0). The client once establishing a connection won't disconnect forever so the # of connections per hour would only go up. That's why I'm wondering. Any help, links, tips, etc would be appreciated. Thanks, San.

##### Share on other sites
The number of sockets a program can have open is a function of the limits put on the process, limitations on the select() function, and the system limit on file descriptors. Post-2.2.something linux kernels have effectively no fd limit. If you're trying to select() on them you'll run into FD_SETSIZE, which is 1024 if I recall correctly; I believe the actual syscall has no limits, but some fixed-size buffer is required so the fd_set can be completely stack-allocated. Just use poll() or some other socket-readiness-notification mechanism instead if that matters. The process file-descriptor limit can be found (and set by root) with "ulimit -n".

##### Share on other sites
Limits are as follows:

1. listen() - this only affects non-accepted connections. It might be ignored by the OS anyway

2. Per-process file descriptor limit - set by ulimit or sysctl - the default is 1024 - but of course not all of those can be used for sockets as some will be used for other things too.

This can be increased by root using ulimit - not sure if "su" resets it - read about ulimit - there is probably some way of changing the default for certain processes.

3. System-wide FD limit - this can be set with sysctl in /proc/sys/fs/file-max

On mine it seems to be 26208

4. Using select() limits you to FD_SETSIZE. Using select() is not the preferred way of waiting for a large number of file descriptors. Try poll (or better still epoll) instead - they have no theoretical limit.

4. Any hard-coded limits - I don't think so. Ultimately however, you wil be limited by the amount of kernel memory each socket takes up - which will be finite - perhaps as much as 64k - they have buffers. This memory is not swappable AFAIK, so it will be limited by physical RAM.

Probably system performance will become very low before you reach the memory limit, consider getting more ram if you need that many.

10k doesn't sound like a problematic number, 1 million might be pushing it.

Mark

##### Share on other sites
Hello,
Thank you for the reply. I'm using a perl script on the server side and checking for the connections using the IO::Select module as

my ( $pending ) = IO::Select->select($handles, undef, undef, 60 );

So this is effectively using the select(). So will you suggest I would have to change my code or can I just change the FD_SETSIZE to a larger value if needs be? My need is actually around 10k only. I guess I will go with poll/epoll if there is lot of speed difference b/w them.

I also tried setting the ulimit command and now I have the following:
[root@sls-cb12p2 server]# ulimit -acore file size        (blocks, -c) 0data seg size         (kbytes, -d) unlimitedfile size             (blocks, -f) unlimitedmax locked memory     (kbytes, -l) unlimitedmax memory size       (kbytes, -m) unlimitedopen files                    (-n) 900000pipe size          (512 bytes, -p) 8stack size            (kbytes, -s) 10240cpu time             (seconds, -t) unlimitedmax user processes            (-u) unlimitedvirtual memory        (kbytes, -v) unlimited[root@sls-cb12p2 server]# cat /proc/sys/fs/file-max50717

Also I haven't done any stress testing for this myself. I couldn't find any tools to do this, so what I have in mind is to write another simple perl script and fork 10,000 connections to this server. Is this a good idea?

Thanks again for the help,
San

##### Share on other sites

This topic is 4833 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628666
• Total Posts
2984133

• 12
• 10
• 9
• 9
• 10