18.04.3 版上,当有约 120,000 个活动连接时,服务器停止接受连接

18.04.3 版上,当有约 120,000 个活动连接时,服务器停止接受连接

我正在运行一种性能测试,其中我有一个简单的 TCP 服务器,它有 4 个 IP 地址,正在监听一个端口并从本地网络上的其他几台计算机获取连接。在活动连接数接近 120,000 之前,一切都运行良好,客户端能够从客户端获取消息并创建新连接。在接近 120,000 时,新连接就停止出现。服务器上没有日志活动,客户端在一段时间后开始超时。没有防火墙会妨碍。我已经调整了一些设置:

/etc/sysctl.conf

net.core.netdev_max_backlog = 1000000

net.core.netdev_budget = 50000
net.core.netdev_budget_usecs = 5000

net.core.somaxconn = 1024000

net.core.rmem_default = 1048576
net.core.rmem_max = 16777216

net.core.wmem_default = 1048576
net.core.wmem_max = 16777216

net.core.optmem_max = 65536

net.ipv4.tcp_rmem = 4096 1048576 2097152
net.ipv4.tcp_wmem = 4096 65536 16777216
net.ipv4.udp_rmem_min = 8192
net.ipv4.udp_wmem_min = 8192
net.ipv4.tcp_fastopen = 3
net.ipv4.tcp_max_syn_backlog = 3000000
net.ipv4.tcp_max_tw_buckets = 2000000

net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_fin_timeout = 10
net.ipv4.tcp_slow_start_after_idle = 0
net.ipv4.tcp_keepalive_time = 60
net.ipv4.tcp_keepalive_intvl = 10
net.ipv4.tcp_keepalive_probes = 6
net.ipv4.tcp_mtu_probing = 1
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_rfc1337 = 1
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.all.rp_filter = 1

/etc/security/limits.conf

* soft nofile 6553600
* hard nofile 6553600
cat /proc/sys/fs/file-max
1621708

这些限制是故意设置的,完全是过度的,因为这只是一个测试。我是否遗漏了其他一些可以启用更多连接的设置?CPU 和 RAM 都没有受到压力,所以我想继续推动硬件。服务器和客户端都在 AWS EC2 t3a.xlarge 实例上运行,如果这有任何区别的话。

答案1

原来这是 AWS 的限制。显然,同一 VPC 内的 EC2 实例之间的通信活动连接限制约为 120,000。让它们使用公共 IP 进行通信可以摆脱这一限制。我在 Ubuntu 中没有收到任何错误,因为操作系统没有限制任何东西。

相关内容