V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
weiruanniubi
V2EX  ›  程序员

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

  •  
  •   weiruanniubi · 2019-09-12 12:25:41 +08:00 · 4078 次点击
    这是一个创建于 1659 天前的主题,其中的信息可能已经有所发展或是发生改变。

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

    11 条回复    2019-09-12 15:45:24 +08:00
    PureWhiteWu
        1
    PureWhiteWu  
       2019-09-12 12:29:01 +08:00
    请自己先 Google。
    去看看内核中对于 fastopen 值的定义是什么就能理解了。
    weiruanniubi
        2
    weiruanniubi  
    OP
       2019-09-12 12:30:00 +08:00
    @PureWhiteWu 内核的值我知道,1 是服务端开启,2 是客户端开始,3 是全部开启。但是 NGINX 的我不理解,谷歌也没有。
    ysc3839
        3
    ysc3839  
       2019-09-12 12:45:43 +08:00 via Android
    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
        4
    PureWhiteWu  
       2019-09-12 12:50:04 +08:00
    https://nginx.org/en/docs/http/ngx_http_core_module.html
    只能帮你到这里了。
    自行关键字搜索。
    swulling
        5
    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
        6
    weiruanniubi  
    OP
       2019-09-12 12:57:20 +08:00
    @ysc3839
    @PureWhiteWu
    看完之后,我决定还是禁用了吧……
    weiruanniubi
        7
    weiruanniubi  
    OP
       2019-09-12 12:59:58 +08:00
    @swulling 去掉了,感觉弊大于利的样子……
    swulling
        8
    swulling  
       2019-09-12 13:03:46 +08:00 via iPhone
    国内的配置文档就是瞎 JB 抄,有人按照内核的习惯设置为 3,结果都变成了 3,也没一个人验证下到底开启了没有。 国外的文章就很正常,还有 test code。
    swulling
        9
    swulling  
       2019-09-12 13:04:30 +08:00 via iPhone
    @weiruanniubi 还好,主要是降低了 latency。看你的应用是否对 latency 敏感。
    weiruanniubi
        10
    weiruanniubi  
    OP
       2019-09-12 13:07:20 +08:00
    @swulling 是的,我也觉得是把内核值和这个搞混了……
    xgfan
        11
    xgfan  
       2019-09-12 15:45:24 +08:00
    这种参数一般两种选择
    + 看官网文档,调整之后自己测试。
    + 假装不存在,直接删掉用默认的。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2697 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 15:45 · PVG 23:45 · LAX 08:45 · JFK 11:45
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.