nginx重启瞬间有请求进来,怎么办?

最近在看无中断更新系统,其中一个策略“滚动部署”,利用nginx来逐步停丢部分转发,来更新系统。

比较疑惑的是,如果在修改完nginx配置后,reload命令的瞬间,有请求进来,是不是这个请求就丢失了?

那这样还算是无中断更新系统吗?

阅读 3.4k
1 个回答

nginx -s reload 专门用来在线更新配置,并不需要重启。任何请求都不会丢失。

In order for nginx to re-read the configuration file, a HUP signal should be sent to the master process. The master process first checks the syntax validity, then tries to apply new configuration, that is, to open log files and new listen sockets. If this fails, it rolls back changes and continues to work with old configuration. If this succeeds, it starts new worker processes, and sends messages to old worker processes requesting them to shut down gracefully. Old worker processes close listen sockets and continue to service old clients. After all clients are serviced, old worker processes are shut down.
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题