Django’s dev server causes permanent high CPU load with Python 3

cpu loadperformancepythonpython3

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.

Best 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

Related Question