增加出站 TCP 连接的数量

增加出站 TCP 连接的数量

我正在开发一个用于 websockets 的小型测试客户端。我使用的是 Ubuntu 11.04。我已阅读 https://stackoverflow.com/questions/410616/increasing-the-maximum-number-of-tcp-ip-connections-in-linux我已经做了以下事情

sudo sysctl -w  net.ipv4.tcp_fin_timeout=10 
sysctl -w net.ipv4.ip_local_port_range="1024 65535" 

据我了解,这些适用于入站连接,而不是出站连接。

当我输入

ulimit -n
unlimited

我的客户端和服务器在不同的机器上运行。即使有上述所有方法,我也无法在一个机器上跨越超过 1000 个连接。如果有其他提示,请告诉我

回答 我通过输入 ulimit -a 来计算这一点,它显示了所有内核限制。

ulimit -n 
unlimited 

尽管

ulimit -a 

返回 nofile 的值 1024。我在/etc/security/limits.conf格式的文件

 <user> soft nofile 8192 
 <user> hard nofile 65000 

并且一切对用户有用

答案1

我通过输入 ulimit -a 来计算,它显示了所有内核限制。ulimit -n 返回无限制,而 ulimit -a 返回 nofile 的值为 1024。我在 /etc/security/limits.conf 文件中以 ** soft nofile 8192 hard nofile 65000 格式设置限制,一切正常

相关内容