58
1,000,000 Concurrent Connections

1,000,000 Concurrent Connections

2 years ago
ian $1xyBFp19aD

https://josephmate.github.io/2022-04-14-max-connections/

I hear the misconception that a server can only accept 65K connections or a server consumes a port for each accepted connection all the time. Here is a taste of some of them:

A TCP/IP address only supports 65,000 connections, so you would have to have to assign around 30,000 IP addresses to that server.

There are 65535 TCP port numbers, does that mean only 65535 clients can connect to a TCP server? One might think that this places a hard limit on the number of clients that a single computer/application can maintain.

If there is a limit on the number of ports one machine can have and a socket can only bind to an unused port number, how do servers experiencing extremely high amounts (more than the max port number) of requests handle this? Is it just done by making the system distributed, i.e., many servers on many machines?

So I put together this article to dispel this myth from three directions:

WhatsApp, a chatting app you have probably used, and Phoenix, a web framework built on top of Elixir, have already demonstrated millions of connections listening to a single port.
What is theoretically possible based on the TCP/IP protocol
A simple Java experiment anyone can run on their machine if they are still not convinced.
Jump to the summary at the end if you want to skip the details.