Max Concurrent TCP Connections on Windows XP

Started by
9 comments, last by cmroche 15 years, 9 months ago
Hi, I have a C# server that just stops when I have around 3985 concurrent connections established. At the same time, I cannot open a web browser page, indicating my system has run out of TCP resources (or something). I did some research and found that there are some settings one can play with found at HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Tcpip\Parameters. I added MaxUserPorts and gave it a vlaue of 65535. I also added TcpTimedWaitDelay and reduced it to 30 seconds. I have also introduced a new value MaxFreeTcbs and set that to 20000. Nothing seems to work. I dont know how to progress. Any advice? Thanks, D.
Advertisement
It seems there is something wrong with my development box. If I apply the aforementioned registry settings on my laptop, I can successfully create 9999 concurrent connections. I dont know how to get more though.

In the real-world, surely its expected that a server should handle many concurrent users over TCP? I am wondering if I have my design wrong. Each simulated connection creates a TCP socket to the server, and keeps it open. The idea is that during game-play, this is how it would work - each client has an open connection to send and receive updates.

Stuck.

D.
What version of XP do you have on the laptop and desktop? Home or Premium? And what service pack?

And I assume you are restarting after changing these registry settings, right?
Yes, servers can have more sockets. If you install Windows Server 2003, for example, you will be able to create many more sockets. That's why they have separate server versions of the OS.
enum Bool { True, False, FileNotFound };
Hi guys,

Yes I have rebooted. I have XP Professional with the latest service pack.

Maybe this is as good as it gets on XP Professional...

D.
Quote:Original post by Dzogchener
I have a C# server that just stops when I have around 3985 concurrent connections established. At the same time, I cannot open a web browser page, indicating my system has run out of TCP resources (or something).


How is this server implemented? I seem to remember reading once that you can only get about 4000 threads on Windows XP, and the figure you cited seems suspiciously close to that number, if you had 1 thread per connection for example. It seems more likely that performance would drop to nothing long before you got that far though!
I found that network drivers can play a role too, but one cannot do much about it.

On same machine, under Windows, server would choke with ~300 connections, wheras under Linux, it would scale nicely to thousands (and no, server design was not the problem).

Even trying different NICs on same machine resulted in different numbers. While most lower-end NICs do the job, they really dislike the stress tests. Same for various home routers, which are somewhat easy to choke. One major issue is overload behavior. Even if a card works well up until available bandwidth, once packets start overflowing, some just peg the CPU, or start dropping packets left and right. This appears to be especially bad with built-in (gigabit even) NIC, despite supposed availability of various options in adapter settings.

If going the 10k+ connections route, some solid hardware will be a pre-requisite. Still, I somewhat doubt that this is a realistic scenario. 10k+ connections, if not used for something trivial, like serving static web pages, is quite a large number, especially since 'game' was mentioned.
Depending in which way you're implementing your managed networking code, the most likely options for the slowdown are:Or some mixture of these. The details you provided don't really tell much about the reasons. You could run Perfmon and check if you see something like context switching going on in your code. Network tracing could be of help also.

Also, MSDN documentation tells here
Windows is capable of servicing over 200,000 simultaneous TCP connections
Which is quite a many connections.

If you want to write some high-performance managed networking code SocketAsyncEventArgs is the way to. This is what I have used successfully at work.
---Sudet ulvovat - karavaani kulkee
Quote:Original post by Dzogchener
Hi,

I have a C# server that just stops when I have around 3985 concurrent connections established.

D.


I'm not sure about it help for you.
I got first limitation of connection when system can't allocate memory for TCP buffer. For example (32k+32k) Receive/Send buffer * 4000 connection. System must have free 256Mb memory. 32k is minimum size, could be more.

Hi,

Naurava, your response is very informative. Slowness was never an issue, just the the connections cease once a limit is reached. However, all of the issue around performance and the GC are sound, and fortunately in my line of work I am very familiar with them. I was not familiar with the new socket stuff from MS - thank you for this. I have typically built most of this infrastructure underneath, so its nice to see MS provide much of it now.

Again many thanks,

D.

This topic is closed to new replies.

Advertisement