uWSGI downtime when restart uWSGI downtime when restart nginx nginx

uWSGI downtime when restart


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 filelazy-apps = truetouch-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