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

不懂就要问,请教大神一个 NGINX 的问题。

  •  1
     
  •   VIPID · 2019-06-18 09:48:07 +08:00 · 1636 次点击
    这是一个创建于 1771 天前的主题,其中的信息可能已经有所发展或是发生改变。

    看到一些 NGINX 安装教程中有以下操作:
    编译参数添加 --with-cc-opt=-DTCP_FASTOPEN=23
    然后配置文件监听端口后面添加 fastopen=3 reuseport
    我想知道:
    1.这是干什么的,能带来哪些好处?
    2.等号后面的数字,代表什么意思,是否还有其他值可选?

    CivAx
        1
    CivAx  
       2019-06-18 11:06:56 +08:00
    tcp_fastopen 是在 CentOS 3.10 (是不是啊,我不太记得具体版本了,我在用 5.1 )上被支持的特性

    具体干啥的可用自己查,大致来说就是我们俩握过手 py 过,下次见面就不用再握了,直接 py。这个主要依靠 cookies 判断(需要客户端、服务端、程序一并支持)

    --with-cc-opt 代表在构建时自定义一个额外参数,然后在构建时传给 C 编译器
    [值得收藏: https://www.ttl178.com/thread-13-1-2.html]

    -D TCP_FASTOPEN 是启用 TCP_FastOpen,并使用选项 2 和 3。实际上通常是用 2,3 代表 1+2 ;要么 2,要么 3

    关于 FastOpen:
    tcp_fastopen - INTEGER
    Enable TCP Fast Open feature (draft-ietf-tcpm-fastopen) to send data in the opening SYN packet. To use this feature, the client application must use sendmsg() or sendto() with MSG_FASTOPEN flag rather than connect() to perform a TCP handshake automatically.

    The values (bitmap) are
    1: Enables sending data in the opening SYN on the client w/ MSG_FASTOPEN.
    丨 允许在已建立的 SYN 链接中使用 MSG_FastOpen [发送]数据
    2: Enables TCP Fast Open on the server side, i.e., allowing data in a SYN packet to be accepted and passed to the application before 3-way hand shake finishes.
    丨 允许服务器端使用 TCP FastOpen,意思是说允许在三次握手完成前就开始[接收] SYN 包中的数据(这就是 FastOpen 的意义,类似于总开关,想用就必开)
    4: Send data in the opening SYN regardless of cookie availability and without a cookie option.
    丨 无论是否存在 cookies,都允许向任何未校验的 SYN 链接[发送]数据
    0x100: Accept SYN data w/o validating the cookie.
    丨 不验证 Cookies,[接收]任何 SYN 数据
    0x200: Accept data-in-SYN w/o any cookie option present.
    丨 接受没有任何 cookie 选项的 SYN-in-SYN 数据
    0x400/0x800: Enable Fast Open on all listeners regardless of the TCP_FASTOPEN socket option. The two different flags esignate two different ways of setting max_qlen without the TCP_FASTOPEN socket option.
    丨 看不懂

    Default: 1

    Note that the client & server side Fast Open flags (1 and 2 respectively) must be also enabled before the rest of flags can take effect.

    See include/net/tcp.h and the code for more details.
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5755 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 06:28 · PVG 14:28 · LAX 23:28 · JFK 02:28
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.