Server单个端口(socket)最大并发连接数
可以在同一端口(单套接字)上与服务器通信的并发客户端(使用不同端口号)的最大数量是多少?哪些因素可能影响这个计数?我正在寻找有关 Linux 环境中的 telnet 的信息。
What could be the maximum number of concurrent Clients (using different port number) that could communicate to a Server on the same port (Single socket) ? What are the factors that could influence this count ? I am looking for this information w.r.t telnet in Linux environment.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这部分取决于您的操作系统。
然而,对特定端口没有限制。然而,并发连接的数量是有限制的,通常受到内核支持的文件描述符数量的限制(例如2048)。
要记住的是,TCP 连接是唯一的,并且连接是一对端点(本地和远程 IP 地址和端口),因此如果 1000 个连接连接到服务器上的同一端口并不重要,因为这些连接是一切仍然是独特的,因为另一端不同。
需要注意的另一个限制是机器只能建立大约 64K 出站连接或连接的内核限制,以较低者为准。这是因为端口是一个无符号 16 位数字 (0-65535),并且每个出站连接都使用这些端口之一。
您可以通过为计算机提供额外的 IP 地址来扩展此功能。每个IP地址都是另一个64K地址的地址空间。
This depends in part on your operating system.
There is however no limit on a specific port. There is a limit on the number of concurrent connections however, typically limited by the number of file descriptors the kernel supports (eg 2048).
The thing to remember is that a TCP connection is unique and a connection is a pair of end points (local and remote IP address and port) so it doesn't matter if 1000 connections connect to the same port on a server because the connections are all still unique because the other end is different.
The other limit to be aware of is that a machine can only make about 64K outbound connections or the kernel limit on connections, whichever is lower. That's because port is an unsigned 16 bit number (0-65535) and each outbound connection uses one of those ports.
You can extend this by giving a machine additional IP addresses. Each IP address is another address space of 64K addresses.
比你关心的还要多。或者更确切地说。
我可以保证它比所有这些都重要。大量套接字存在可扩展性限制,可以解决这个问题(Google 解决了 c10k 问题)。实际上,Linux 下的单个进程可以使用超过 10,000 个有效的套接字。如果每台服务器有多个进程,则可以再次增加进程。
不必使用单个端口,因为您的专用负载平衡器将能够在需要时循环多个端口。
如果您正在为数十甚至数千个客户端进程运行一个服务,那么它的持续工作可能相当重要,因此您无论如何都需要多台服务器来实现冗余。因此,部署更多服务器不会有问题。
More than you care about. Or rather.
I can guarantee that it is more than all of those. There are scalability limitations with large numbers of sockets, which can be worked around (Google for the c10k problem). In practice it is possible to have more than 10,000 sockets usefully used by a single process under Linux. If you have multiple processes per server, you can increase that up again.
It is not necessary to use a single port, as your dedicated load-balancers will be able to round-robin several ports if needed.
If you are running a service for many 10s of 1000s of client processes, it is probably fairly important that it keeps working, therefore you will need several servers for redunancy ANYWAY. Therefore you won't have a problem deploying a few more servers.
我在 Windows 上进行了测试,在单个套接字上进行多个环回连接。 Windows 拒绝在 16372 标记之后分配任何内容。
I did a testing on Windows, doing multiple loopback connections onto a single socket. Windows refused to allocate anything after 16372 mark.