uWSGI downtime when restart

試著忘記壹切 提交于 2019-12-06 20:56:31

This is how uwsgi does graceful reload. Keeps old processes until requests are served and creates new ones that will take over incoming requests.

Read Things that could go wrong

Do not forget, your workers/threads that are still running requests could block the reload (for various reasons) for more seconds than your proxy server could tolerate.

And this

Another important step of graceful reload is to avoid destroying workers/threads that are still managing requests. Obviously requests could be stuck, so you should have a timeout for running workers (in uWSGI it is called the “worker’s mercy” and it has a default value of 60 seconds).

So i would recommend trying worker-reload-mercy

Default value is to wait 60 seconds, just lower it to something that your server can handle.

Tell me if it worked.


Uwsgi chain reload

This is another try to fix your issue. As you mentioned your uwsgi workers are restarting in a manner described below:

  1. send SIGHUP signal to the master
  2. Wait for running workers.
  3. Close all of the file descriptors except the ones mapped to sockets.
  4. Call exec() on itself.

One of the cons of this kind of reload might be stuck workers. Additionaly you report that your server crashes when uwsgi maintains 10 proceses (5 old and 5 new ones).

I propose trying chain reload. DIrect quote from documentation explains this kind of reload best:

When triggered, it will restart one worker at time, and the following worker is not reloaded until the previous one is ready to accept new requests.

It means that you will not have 10 processes on your server but only 5.

Config that should work:

# your .ini file
lazy-apps = true
touch-chain-reload = /path/to/reloadFile

Some resources on chain reload and other kinds are in links below:

Chain reloading uwsgi docs

uWSGI graceful Python code deploy

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!