views:

4068

answers:

7

Has anyone an idea how many tcp-socket connections are possible on a modern standard root server? (There is in general less traffic on each connection, but all the connections have to be up all the time.)

EDIT: We will use a Linux Server.

+3  A: 

This depends not only on the operating system in question, but also on configuration, potentially real-time configuration.

For Linux:

cat /proc/sys/fs/file-max

will show the current maximum number of file descriptors total allowed to be opened simultaneously. Check out http://www.cs.uwaterloo.ca/~brecht/servers/openfiles.html

Eddie
A: 

Realistically for an application, more then 4000-5000 open sockets on a single machine becomes impractical. Just checking for activity on all the sockets and managing them starts to become a performance issue - especially in real-time environments.

sean riley
Will all due respect, that's rubbish. Using I/O completion ports and overlapped I/O on a modestly specified Windows box you can easily handle 10-20,000 connections and the only limit tends to be non-paged memory for pending async operations. 4-5000 connections, with a modern design, is, IMHO, easy.
Len Holgate
Overly broad statement. In reality, it all depends on what you're doing at the application layer; that's going to be your performance bottleneck in almost all cases.
DarkSquid
+1  A: 

Google around for the "C10K" problem. This is basically discussion and technology around managing 10,000 or more simultaneous connections.

I suspect this number was chosen because it's hard, but theoretically possible.

Darron
A: 

For Windows, see this question Which is the maximum number of Windows concurrent tcp/ip connections?

lsalamon
+1  A: 

Which operating system?

For windows machines, if you're writing a server to scale well, and therefore using I/O Completion Ports and async I/O, then the main limitation is the amount of non-paged pool that you're using for each active connection. This translates directly into a limit based on the amount of memory that your machine has installed (non-paged pool is a finite, fixed size amount that is based on the total memory installed).

For connections that don't see much traffic you can reduce make them more efficient by posting 'zero byte reads' which don't use non-paged pool and don't affect the locked pages limit (another potentially limited resource that may prevent you having lots of socket connections open).

Apart from that, well, you will need to profile but I've managed to get more than 70,000 concurrent connections on a modestly specified (760MB memory) server; see here http://www.lenholgate.com/archives/000568.html for more details.

Obviously if you're using a less efficient architecture such as 'thread per connection' or 'select' then you should expect to achieve less impressive figures; but, IMHO, there's simply no reason to select such architectures for windows socket servers.

Edit: see here http://blogs.technet.com/markrussinovich/archive/2009/03/26/3211216.aspx; the way that the amount of non-paged pool is calculated has changed in Vista and Server 2008 and there's now much more available.

Len Holgate
Hmm. Interesting. With 128mb of non-paged pool on W2K, with IOCP, I could sustain 4,000 *active* sockets (e.g. concurrently streaming). When those sockets are idle, I could sustain about 16,000. I'm guessing your sockets are idle and/or this zero byte read ticket helped.
Blank Xavier
Define active. You are running the test client on a different machine? You are managing the amount of data that you're sending using some form of flow control? My sockets were echoing messages, but weren't using zero byte read. They weren't running flat out and streaming data as fast as possible.
Len Holgate
I thought you could only get 65k connections on Windows - you have to edit the tcpnumconnections registry setting. (and on XP they limit it further in tcpip.sys, there was a lot of talk about this on bittorrent sites)
gbjbaanb
you're getting confused, I think. The limit in tcpip.sys is for half open connections and acts as a limit on the number of concurrent connects that you can have in progress at any one time. The MaxUserPort registry entry restricts the number of client ports, so the maximum value that you can set there is going to limit the number of OUTBOUND connections you can establish would be limited by that. There's no limit to the number of INBOUND connections possible.
Len Holgate
+2  A: 

On Linux you should be looking at using epoll for async I/O. It might also be worth fine-tuning socket-buffers to not waste too much kernel space per connection.

I would guess that you should be able to reach 100k connections on a reasonable machine.

cmeerw
+2  A: 

10,000? 70,000? is that all :)

FreeBSD is probably the server you want, Here's a little blog post about tuning it to handle 100,000 connections, its has had some interesting features like zero-copy sockets for some time now, along with kqueue to act as a completion port mechanism.

Solaris can handle 100,000 connections back in the last century!. They say linux would be better

The best description I've come across is this presentation/paper on writing a scalable webserver. He's not afraid to say it like it is :)

Same for software: the cretins on the application layer forced great innovations on the OS layer. Because Lotus Notes keeps one TCP connection per client open, IBM contributed major optimizations for the ”one process, 100.000 open connections” case to Linux

And the O(1) scheduler was originally created to score well on some irrelevant Java benchmark. The bottom line is that this bloat benefits all of us.

gbjbaanb
I stopped at 70,000 because it was more than my client required; so the test had been passed. With changes in how non-paged pool limits are calculated I would imagine that a windows server 2008 machine would have no problem with 100,000 connections.
Len Holgate