• 请不要在回答技术问题时复制粘贴 AI 生成的内容
moonsn
V2EX  ›  程序员

请教一个 nginx 超时限制问题

  •  2
     
  •   moonsn · Nov 11, 2019 · 3266 views
    This topic created in 2567 days ago, the information mentioned may be changed or developed.
    proxy_read_timeout 10ms;
    

    如上配置,如果一个 response 由于某些原因,每 9ms 进行了一次传输(由于两次读操作在 timeout 限制内,所以不会超时)。多次传输才传完 response 的话,假如 response 整体 10ms 超时,response 整体是超时的。这个整体的超时要怎么控制?

    The timeout is set only between two successive read operations, not for the transmission of the whole response.

    附官网指令文档:

    Syntax:	proxy_read_timeout time;
    Default:	
    proxy_read_timeout 60s;
    Context:	http, server, location
    

    Defines a timeout for reading a response from the proxied server. The timeout is set only between two successive read operations, not for the transmission of the whole response. If the proxied server does not transmit anything within this time, the connection is closed.

    Supplement 1  ·  Nov 11, 2019
    对不起,我没有描述原始需求。

    我有个 subrequest 请求,用于获取旁路的信息,比如用户认证什么的。

    但是我希望能有个超时机制。使用 proxy_read_timeout 并不能真正做到我想要的限制 response 整体超时。
    9 replies  •  2019-11-12 01:12:38 +08:00
    Oa
    Oa
    Nov 11, 2019
    1
    一小时 8 分钟过去了。。。。。
    moonsn
    moonsn
    OP
    Nov 11, 2019
    2
    @Oa 估计是问题比较偏?
    dppd
    dppd
    Nov 11, 2019
    3
    其实还不太明白你的意思...从 keepalive 和 HTTP1.1 入手?
    moonsn
    moonsn
    OP
    Nov 11, 2019 via Android
    4
    @dppd append 了

    我有个 subrequest 请求,用于获取旁路的信息,比如用户认证什么的。

    但是我希望能有个超时机制,这样不至于让旁路拖慢了主请求。使用 proxy_read_timeout 并不能真正做到我想要的限制 response 整体超时。
    moonsn
    moonsn
    OP
    Nov 11, 2019 via Android
    5
    @dppd 感谢,我试试 keepalive
    eason1874
    eason1874
    Nov 11, 2019
    6
    “多次传输才传完 response 的话,假如 response 整体 10ms 超时,response 整体是超时的。”

    估计大家都看不懂你说什么,怀疑自己水平不够,于是进来看一眼又退出了。你可以把 Nginx 所有 _timeout 结尾的配置都看一遍,看哪个适合你。
    azh7138m
    azh7138m
    Nov 11, 2019
    7
    send_timeout ?
    moonsn
    moonsn
    OP
    Nov 11, 2019
    8
    @eason1874 嗯,确实描述有问题,append 的需求是否简单明了?
    dndx
    dndx
    Nov 12, 2019
    9
    OpenResty `body_filter_by_lua` 可以根据已经花在处理上的时间终止请求。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2056 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 02:46 · PVG 10:46 · LAX 18:46 · JFK 21:46
    ♥ Do have faith in what you're doing.