开发者社区> 问答> 正文

谁测试过SOCKET TCP 的BACKLOG的上限的?:报错

最近在重新整理SOCKET的资料。对于listen (std,backlog);

后面是一个listen可以保持最大连通数,简单这么解释吧。现在man上表明可以通过修改

tcp_max_syn_backlog 的值来调整。

建议可以调整到1024个。传统的都是3到5个。但是man并没有确定最大,只是说了建议在1024对应要调整其他东西,recompile kernel 。

有谁做过对listen 的backlog最大值的测试的?。man的摘抄如下:

tcp_max_syn_backlog (integer; default: see below; since Linux 2.2)

The maximum number of queued connection requests which have still not received an acknowledgement from the connecting client. If this number is exceeded, the kernel will begin dropping requests. The default value of 256 is increased to 1024 when the memory present in the system is adequate or greater (>= 128Mb), and reduced to 128 for those systems with very low memory (<= 32Mb). It is recommended that if this needs to be increased above 1024, TCP_SYNQ_HSIZE ininclude/net/tcp.h be modified to keep TCP_SYNQ_HSIZE*16<=tcp_max_syn_backlog, and the kernel be recompiled.


如果有以下数据就最好了。基于同样内存下超过16G,backlog不同的值下超过512个,accept的响应时间,connect满时,两个相邻accept之间的CPU时间。我担心,backlog就是增长,假设在网络速度足够快下,较多的client 的connect 也会加重OS kernel的处理负载,并导致平均处理能力下降。

不知道哪位在学校的朋友,能否帮忙翻翻有没有类似的测试的论文或文献?我现在手头上的机器怕网络不够,测不到峰值。


 

 


展开
收起
kun坤 2020-06-14 10:57:16 574 0
1 条回答
写回答
取消 提交回答
  • The behavior of the backlog argument on TCP sockets changed with Linux 2.2. Now it specifies the queue length for completely established sockets waiting to be accepted, instead of the number of incomplete connection requests.

    上面这句要注意,现在他指的是已连接但未进行accept 处理的套接字,而不是syn的套接字,我一般设成64左右。所以现在关注的可能是 /proc/sys/net/core/somaxconn这个参数,而非tcp_,ax_sync_backlog,这个参数对一些防火墙应该有用(半syn攻击)

    The maximum length of the queue for incomplete sockets can be set using /proc/sys/net/ipv4/tcp_max_syn_backlog. When syncookies are enabled there is no logical maximum length and this setting is ignored. Seetcp(7) for more information.

    If the backlog argument is greater than the value in /proc/sys/net/core/somaxconn, then it is silently truncated to that value; the default value in this file is 128. In kernels before 2.4.25, this limit was a hard coded value, SOMAXCONN, with the value 128.

    ######

    tcp_max_syn_backlog其实也容易测,找个syn的dos工具应该就行。

    backlog其实也容易测,只要listen不accpet,这个backlog就会增加了。

    ######

    单机测试,由于端口限制,测试到5W个。

    多机理论上服务器端能容纳任意多个吧,只要内存足够。

    ######

    引用来自“bastetwang”的答案

    tcp_max_syn_backlog其实也容易测,找个syn的dos工具应该就行。

    backlog其实也容易测,只要listen不accpet,这个backlog就会增加了。

    我是说有效处理,简化accept后面的工作。但不是说猴子摘玉米,来一个丢一个。
    ######

    引用来自“郭煜”的答案

    单机测试,由于端口限制,测试到5W个。

    多机理论上服务器端能容纳任意多个吧,只要内存足够。

    主要关心上限和随着数量的提升,系统性能下降的关系。另外我说的是单机一个端口的连接池的容量。不是多机多端口。
    ######你没仔细看回复,tcp_max_syn_backlog这个值不用测,跟backlog没关系了。######

    引用来自“bastetwang”的答案

    你没仔细看回复,tcp_max_syn_backlog这个值不用测,跟backlog没关系了。
    我关注的是有效的单端口,可保留的连接数量。
    2020-06-14 10:57:22
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
移动互联网测试到质量的转变 立即下载
给ITer的技术实战进阶课-阿里CIO学院独家教材(四) 立即下载
F2etest — 多浏览器兼容性测试整体解决方案 立即下载