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.
Asked
Active
Viewed 3,367 times
1 Answers
5
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
Simon Steinberger
- 350
- 3
- 12
-
3Just wanted to contribute that this was also what was causing the high CPU problem for me. Like Simon said adding `--noreload` to the `runserver` 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. – flatterino Aug 21 '17 at 13:50
-
Dev server runs at 100% CPU usage when idling, `--noreload` solves it – run_the_race Aug 22 '22 at 12:24