nginx - 超时后不正常的工作人员终止
nginx - ungraceful worker termination after timeout
我打算使用 nginx 来代理 websockets。在执行 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 来代理 websockets。在执行 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。