Python – Why are the uWSGI processes dying immediately

processpythonsupervisorduwsgi

I'm using Supervisor and the uWSGI Emperor mode. When I set limit-as to 512 (MB), workers die instantly (respawn, die, respawn, die, every 3/4 of a second or so):

[uwsgi]
workers = 4
threads = 40
limit-as = 512
harakiri = 20
max-requests = 1600
... non-performance/memory/processor-related settings ommitted

But, if I change limit-as to:

[uwsgi]
workers = 4
threads = 40
limit-as = 1024
harakiri = 20
max-requests = 1600
... non-performance/memory/processor-related settings ommitted

and restart uwsgi, the problem is gone immediately. In order to put a sham in this, I've modified the setting back to 512, restarted again, and the problem is back immediately.

Notes: My app is a simple Django app without much additional Python setup during start-up time.

Best Answer

it looks like 512M address space is not enough for your app. If you have to respect such a limit decrease the number of threads or reduce their stacksize with thread-stack-size = 512 (512k is generally the minimal amount for a python app)