gpt4 book ai didi

nginx - 超时后不正常的 worker 终止

转载 作者:行者123 更新时间:2023-12-04 12:49:22 30 4
gpt4 key购买 nike

我打算使用 nginx 来代理 websocket。在执行 nginx reload/HUP 时,我知道 nginx 等待旧的工作进程停止处理所有请求。然而,在 websocket 连接中,这可能不会发生很长时间,因为连接是持久的。是否有选项/路线图可以在重新加载超时后强行杀死旧的工作进程?

引用:

http://nginx.org/en/docs/control.html

http://forum.nginx.org/read.php?21,247573,247651#msg-247651

谢谢

最佳答案

除非您有任何解决方案:proxy_read_timeout 1d 或 ping 消息以保持连接事件,否则 Nginx 将在 60 秒内关闭连接。选择此默认值是有原因的。

看什么Nginx核心开发者says :

There is proxy_read_timeout (http://nginx.org/r/proxy_read_timeout) which as well applies to WebSocket connections. You have to bump it if your backend do not send anything for a long time. Alternatively, you may configure your backend to send websocket ping frames periodically to reset the timeout (and check if the connection is still alive).



话虽如此,没有什么可以阻止您使用 USR2+QUIT 信号组合,通常在您 时使用。优雅二进制升级时重启 Nginx。 Nginx master/worker 进程很少消耗超过 50MB 的内存,因此保持多个 master 并不昂贵。 USR2 有助于 fork 新的 master 并生成其 worker,然后优雅地关闭旧的 worker 和 master。

关于nginx - 超时后不正常的 worker 终止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32496799/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com