现代Linux机顶盒可打开的TCP连接的理论最大数量是多少 [英] What is the theoretical maximum number of open TCP connections that a modern Linux box can have

查看:124
本文介绍了现代Linux机顶盒可打开的TCP连接的理论最大数量是多少的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设硬件具有无限的性能,Linux盒可以支持> 65536个开放的TCP连接吗?

Assuming infinite performance from hardware, can a Linux box support >65536 open TCP connections?

我了解临时端口(<65536)的数量限制了从一个本地IP到一个远程IP上一个端口的连接数量.

I understand that the number of ephemeral ports (<65536) limits the number of connections from one local IP to one port on one remote IP.

元组(本地ip,本地端口,远程ip,远程端口)是唯一定义TCP连接的元组;这是否意味着如果这些参数中的一个以上空闲,则可以支持65K以上的连接.例如通过多个本地IP连接到多个远程主机上的单个端口号.

The tuple (local ip, local port, remote ip, remote port) is what uniquely defines a TCP connection; does this imply that more than 65K connections can be supported if more than one of these parameters are free. e.g. connections to a single port number on multiple remote hosts from multiple local IPs.

系统中还有16位限制吗?可能有多少个文件描述符?

Is there another 16 bit limit in the system? Number of file descriptors perhaps?

推荐答案

单个侦听端口可以同时接受多个连接.

A single listening port can accept more than one connection simultaneously.

通常会引用一个'64K'限制,但这是每个服务器端口的每个客户端,需要澄清.

There is a '64K' limit that is often cited, but that is per client per server port, and needs clarifying.

每个TCP/IP数据包基本上都有四个用于寻址的字段;这些是:

Each TCP/IP packet has basically four fields for addressing; these are:

source_ip source_port destination_ip destination_port
< client            > < server                      >

在TCP堆栈内部,这四个字段用作复合键,用于将数据包匹配到连接(例如文件描述符).

Inside the TCP stack, these four fields are used as a compound key to match up packets to connections (e.g. file descriptors).

如果客户端到同一目的地的同一端口有许多连接,则这些字段中的三个将相同-仅source_port有所不同以区分不同的连接.端口是16位数字,因此,任何给定的客户端可以与任何给定的主机端口建立的最大连接数为64K.

If a client has many connections to the same port on the same destination, then three of those fields will be the same - only source_port varies to differentiate the different connections. Ports are 16-bit numbers, therefore the maximum number of connections any given client can have to any given host port is 64K.

但是,多个客户端可以分别与某个服务器的端口建立多达64K的连接,如果服务器具有多个端口,或者其中一个是多宿主的,则可以进一步将其相乘.

However, multiple clients can each have up to 64K connections to some server's port, and if the server has multiple ports or either is multi-homed then you can multiply that further.

所以真正的限制是文件描述符.每个单独的套接字连接都有一个文件描述符,因此限制实际上是系统已配置为允许文件描述符和资源处理的数量.最大限制通常超过300K,但可以配置,例如与 sysctl .

So the real limit is file descriptors. Each individual socket connection is given a file descriptor, so the limit is really the number of file descriptors that the system has been configured to allow and resources to handle. The maximum limit is typically up over 300K, but is configurable e.g. with sysctl.

例如单线程Jabber消息传递服务器,普通机顶盒的实际限制约为80K.

The realistic limits being boasted about for normal boxes are around 80K for example single threaded Jabber messaging servers.

这篇关于现代Linux机顶盒可打开的TCP连接的理论最大数量是多少的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆