Django's development server runs under Python 2.7.5 (on Windows 7) with a rather constant (idle) load of about 1-3% on my test system - no page loads or other calculations done. Switching to Python 3.4.2 causes the constant load to rise to an average of about 10%. That's pretty huge for not doing anything ... Is there any explanation for it? Can it be avoided? I tested this with various Django apps.
1 Answer
To answer my own question: Django's dev server checks all Python source files periodically for changes. Setting the option --noreload prevents this auto-restart mechanism, which also reduces the idle load to zero. Apparently, auto-reload on Python 3 is less efficient. Using pyinotiy is a solution for Linux to also prevent this overhead: https://docs.djangoproject.com/en/1.7/ref/django-admin/#runserver-port-or-address-port
-
3Just wanted to contribute that this was also what was causing the high CPU problem for me. Like Simon said adding
--noreload
to therunserver
command solved it. Looks like the auto-reload in Django is incredibly wasteful; even without touching or modifying any.py
file, they are reloaded constantly, causing really high CPU and I/O loads. Aug 21, 2017 at 13:50 -
Dev server runs at 100% CPU usage when idling,
--noreload
solves it Aug 22, 2022 at 12:24