NGINX 的 fastopen 这个值填多少比较合适?

2019-09-12 12:25:41 +08:00
 weiruanniubi

这个值还是当初直接复制网上教程的,填的 3。
想知道这个值有没有什么依据,目前配置是 1C1G1M,填多少最好呢?

4098 次点击
所在节点    程序员
11 条回复
PureWhiteWu
2019-09-12 12:29:01 +08:00
请自己先 Google。
去看看内核中对于 fastopen 值的定义是什么就能理解了。
weiruanniubi
2019-09-12 12:30:00 +08:00
@PureWhiteWu 内核的值我知道,1 是服务端开启,2 是客户端开始,3 是全部开启。但是 NGINX 的我不理解,谷歌也没有。
ysc3839
2019-09-12 12:45:43 +08:00
fastopen=number
enables “TCP Fast Open” for the listening socket (1.5.8) and limits the maximum length for the queue of connections that have not yet completed the three-way handshake.
Do not enable this feature unless the server can handle receiving the same SYN packet with data more than once.
http://nginx.org/en/docs/http/ngx_http_core_module.html
PureWhiteWu
2019-09-12 12:50:04 +08:00
https://nginx.org/en/docs/http/ngx_http_core_module.html
只能帮你到这里了。
自行关键字搜索。
swulling
2019-09-12 12:55:31 +08:00
首先你的内核必须支持并且开启了 fastopen

然后这个 number 应该就是 limits the maximum length for the queue of connections that have not yet completed the three-way handshake 里的 limits

写 3 有点小把,可以改成 500

具体是否生效,可以用 tcpdump 把包 dump 出来看看
weiruanniubi
2019-09-12 12:57:20 +08:00
@ysc3839
@PureWhiteWu
看完之后,我决定还是禁用了吧……
weiruanniubi
2019-09-12 12:59:58 +08:00
@swulling 去掉了,感觉弊大于利的样子……
swulling
2019-09-12 13:03:46 +08:00
国内的配置文档就是瞎 JB 抄,有人按照内核的习惯设置为 3,结果都变成了 3,也没一个人验证下到底开启了没有。 国外的文章就很正常,还有 test code。
swulling
2019-09-12 13:04:30 +08:00
@weiruanniubi 还好,主要是降低了 latency。看你的应用是否对 latency 敏感。
weiruanniubi
2019-09-12 13:07:20 +08:00
@swulling 是的,我也觉得是把内核值和这个搞混了……
xgfan
2019-09-12 15:45:24 +08:00
这种参数一般两种选择
+ 看官网文档,调整之后自己测试。
+ 假装不存在,直接删掉用默认的。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/600348

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX