TCP listen() Backlog

Easter79
• 阅读 724

The backlog has an effect on the maximum rate at which a server can accept new TCP connections on a socket. The rate is a function of both the backlog value and the time that connections stay on the queue of partially open connections.

When a TCP connection is being set-up, the client and server perform a three-way handshake to ensure the connection is a valid one. The connection is established when sequence numbers have been exchanged and synchronized in both directions. The sequence numbers are used to provide reliable transmission and flow control (i.e., ensuring either side does not transmit too fast for the other).

TCP listen() Backlog Figure 3. Illustration of Client/Server Connection

As illustrated in Figure 3, the connection is initiated by a listening socket receiving a segment containing a synchronize control flag (SYN) and a sequence number. The server side acknowledges this and sends its own sequence number (SYN|ACK). The client then acknowledges this sequence number (ACK). The connection is established once the server process receives the acknowledgement and performs an accept() system call.

The duration that affects the rate at which new connections are accepted is the time spent on the queue of pending incoming connections. This duration is equal to the round trip time for the SYN|ACK message and its ACK response plus the time taken for the client to process the SYN|ACK message plus the delay for the server to process the ACK and call accept().

The rate at which new connections can be accepted is equal to the number of entries which can fit on the listen queue divided by the average length of time each entry spends on the queue. Therefore, the larger the queue, the greater the rate at which new connection requests can be accepted.

Many systems (particularly BSD-derived or influenced) silently truncate this value (the backlog parameter to the listen() system call) to 5—version 1.2.13 of the Linux kernel does this in /usr/src/linux/net/inet/af_inet.c. Using small values for the listen backlog was one of the major causes of poor web server performance with many operating systems up until recently.

When dealing with Internet applications, you can probably assume that the rate at which new connections can be accepted is equal to the listen backlog divided by the round-trip time of the path between client and server.

The backlog parameter is silently truncated to SOMAXCONN in /usr/src/linux/net/ipv4/af_inet.c. SOMAXCONN is defined as 128 in /usr/src/linux/socket.h for 2.x kernels.

点赞
收藏
评论区
推荐文章
blmius blmius
3年前
MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1
文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s
Wesley13 Wesley13
3年前
java将前端的json数组字符串转换为列表
记录下在前端通过ajax提交了一个json数组的字符串,在后端如何转换为列表。前端数据转化与请求varcontracts{id:'1',name:'yanggb合同1'},{id:'2',name:'yanggb合同2'},{id:'3',name:'yang
待兔 待兔
4个月前
手写Java HashMap源码
HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22
Stella981 Stella981
3年前
Android So动态加载 优雅实现与原理分析
背景:漫品Android客户端集成适配转换功能(基于目标识别(So库35M)和人脸识别库(5M)),导致apk体积50M左右,为优化客户端体验,决定实现So文件动态加载.!(https://oscimg.oschina.net/oscnet/00d1ff90e4b34869664fef59e3ec3fdd20b.png)点击上方“蓝字”关注我
Stella981 Stella981
3年前
PHP Swoole与TCP三次握手
握手常见问题1、连接拒绝2、Operationnowinprogress多是因为丢包、错误ip、backlog满了&阻塞&tcp_abort_on_overflow03、min(maxconn,backlog)sslt连接拒绝在TCP三次握手的时候,客户端发送
Wesley13 Wesley13
3年前
00:Java简单了解
浅谈Java之概述Java是SUN(StanfordUniversityNetwork),斯坦福大学网络公司)1995年推出的一门高级编程语言。Java是一种面向Internet的编程语言。随着Java技术在web方面的不断成熟,已经成为Web应用程序的首选开发语言。Java是简单易学,完全面向对象,安全可靠,与平台无关的编程语言。
Wesley13 Wesley13
3年前
35岁是技术人的天花板吗?
35岁是技术人的天花板吗?我非常不认同“35岁现象”,人类没有那么脆弱,人类的智力不会说是35岁之后就停止发展,更不是说35岁之后就没有机会了。马云35岁还在教书,任正非35岁还在工厂上班。为什么技术人员到35岁就应该退役了呢?所以35岁根本就不是一个问题,我今年已经37岁了,我发现我才刚刚找到自己的节奏,刚刚上路。
Stella981 Stella981
3年前
MFC_TCP_Server
!(https://oscimg.oschina.net/oscnet/44fdf01cd2e73dc5aa35a55874419856565.png)1//New_MFC_TCP_SreverDlg.h:头文件2//3defineWM_SOCKETWM_USER1004pragm
Wesley13 Wesley13
3年前
MySQL部分从库上面因为大量的临时表tmp_table造成慢查询
背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_
Python进阶者 Python进阶者
10个月前
Excel中这日期老是出来00:00:00,怎么用Pandas把这个去除
大家好,我是皮皮。一、前言前几天在Python白银交流群【上海新年人】问了一个Pandas数据筛选的问题。问题如下:这日期老是出来00:00:00,怎么把这个去除。二、实现过程后来【论草莓如何成为冻干莓】给了一个思路和代码如下:pd.toexcel之前把这
Easter79
Easter79
Lv1
今生可爱与温柔,每一样都不能少。
文章
2.8k
粉丝
5
获赞
1.2k