The maximum number of TCP connections I can have in Windows Server 2008

tcpipwindows-server-2008

I would like to have as many connections (single connections from many different clients) as humanly possible in a server running on Windows Server 2008, in order to support a Comet-style application. The application is written in C#. The connections will not be chatty, they just need to be open (and stay open). Buying boatloads of memory and fast CPUs are not a problem.

As far as I can tell, I will be limited to 65k simultaneous open connections per NIC – the maximum number of ports. Is this accurate? Or can I go beyond 65k connections / NIC somehow? It seems like there are server products for Linux at least that support hundreds of thousands of connections. How do they do this?

Best Answer

You can go well beyond 65k connections; as you can have multiple connections per port (once accepted, the listener can connect to another client). One end or the other does have to have some difference, usually the client picks a random port. Windows is by default limited to a few more than 3000 of these random ports; so your typical client will max out around that. It's possible to configure the client differently however, and many *nix are limited to many more than Windows.

There's a registry setting limiting the maximum number of connections to 16 million. But there are other more practical problems that will usually limit you to less (you can change the registry value).

  • Windows takes up about 1KB of RAM per connection (That's ~16GB for 16M connections); and your app will also have to keep track of it's active connections somehow (more memory).
  • Windows will also check for non-responsive connections ever 2 hours. At 16M connections this is about every 0.5 ms; it would take up significant bandwidth just doing those checks.