More than 65536 TCP connections on Linux

Solution 1:

Here is a blog where somebody got > 1,000,000 outbounds from a box.

  • Richard Jones, MetaBrew.com, 2008-11-04, A Million-user Comet Application with Mochiweb, Part 3, section Turning it up to 1 Million (Archived here.)

In Part 1, we set the range to "1024 65535" - meaning there are 65535-1024 = 64511 unprivileged ports available. Some of them will be used by other processes, but we'll never get over 64511 client connections, because we'll run out of ports.

...

So let's bring up 17 new IP addresses, with the intention of making 62,000 connections from each - giving us a total of 1,054,000 connections

Solution 2:

The TCP protocol only uses 16 bits for both destination and source port. There will be no way to have more than 65536 ports open at once - not even with Linux.