django.setup() very slow
We are currently suspecting that slow uWSGI worker startups in a production system can throw uWSGI into a harakiri loop.
I have checked, on a production system with many apps, that django.setup()
takes around 6 seconds, which is the cause for the first request being slow. django.setup()
is called on every request, but is idempotent. On the first request, it initializes just about everything; on all subsequent requests in the same interpreter, it's basically a no-op.
We need to trace what django.setup()
does and why it is slow. Loading every app, loading settings, and calling every app.ready
are the obvious things.