I have a fresh install of django 1.0 and a simple page served from it takes 5 secs to load. On my colleague's computer it takes almost no time.
I start the server using
python manage.py testserver
I can see each GET request (PNGs and style sheets) take about half a second.
Another weird thing, which I think is related, is that the functional tests for the app run much slower on my machine with MySQL (on order of 100 times slower than on my colleague's machine). When I set the app to use sqlite, they run pretty quickly. I would like to exclaim that sqlite doesn't much change the time it takes to load a page, but it does speed up server startup.
It looks like IO problem, but I don't see general performance problems on my machine, apart from django at least.
Django runs on python2.4, I'm running Vista. I have also checked python2.5.
Thanks ΤΖΩΤΖΙΟΥ, It must totaly be a DNS problem, because the page loads up quickly as soon as instead of http://localhost:8000/app I go to http://127.0.0.1:8000/app.
But what could it be caused by? My host file has only two entries:
127.0.0.1 localhost ::1 localhost
Upgrade to Django 1.3 or newer.
If you still have this problem in 2012 (using Chrome), make sure you're upgrading. In 1.3, a bug was fixed related to slowness when the dev server was single threaded.
Upgrading solved my issues. I was running Django 1.2 since that's the default on Debian Squeeze.
To completely bypass localhost without altering the hosts file or any settings in Firefox you can install the addon Redirector and make a rule to redirect from localhost to 127.0.0.1. Use these settings
Leave the other fields empty.
Slow Loading of Static Files
If you notice that static and media files (images, style sheets, etc.) are particularly slow to load, the problem might be Django's development server (
python manage.py runserver
). As noted by hassen, that server is not optimized for speed.You can try using django-extensions
runserver_plus
command with the--threaded
option as a replacement for Django'srunserver
command. Under the hood, it uses Werkzeug as the threaded WSGI server. You may notice a huge improvement in loading times for static files.Also see: Making Django development server faster at serving static media
I have had the same problem in the past. It can be solved by removing the following line from your hosts file.
Once that's gone you should be able to use localhost again, quickly.
Had the same problem too, I've noticed it with Firefox on Vista and Windows 7 machines. Accessing the development server 127.0.0.1:8000 solved the problem.
And if all else fails, you can always cProfile your application and see where exactly is the bottleneck.