Uwsgi memory usage optimisation

djangomemory usageuwsgi

I'm running several django sites on uwsgi, and I'm attempting to optimise my configuration for memory usage, but the –idle and –die-on-idle flags don't seem to be doing anything.

Each daemon starts off at around 10-12MB and increases to around 30MB once it has served a request, but then stays there even when idle for some time. My startup command is:

uwsgi --cheap --idle 60 --die-on-idle --http :8083 --wsgi-file /var/django/mysite/apache/django.wsgi

Is there anything I'm missing here? From the docs, I'd expect the "–idle" flag to make it drop back to its initial memory usage after 60 seconds of idleness; and I'd expect the
"–die-on-idle" flag to kill the worker process completely at that point. Neither of these happen, although the "–cheap" flag does seem to work.

(Note: I realise http isn't the best protocol but I want to get the memory issue sorted before I recompile nginx)

Best Answer

you need the master process to have those options working. If you want to use the http protocol, use --http-socket instead of --http (that will create another process). In addition to this give a look at KSM on the uWSGI wiki