tags:

views:

1522

answers:

9

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
A: 

Disable AV Scanning & see if that makes a difference. It could also be caused by Vista. Upgrade to the latest service pack and try again.

seanyboy
+2  A: 

I think it's the development server, it's not optimized for speed nor security. I noticed that specially serving static files (i.e. media) is slow.

hasen j
+3  A: 

Since you report your friend's machine has no delays, and I assume yours and his are comparable computers, it could be a DNS related issue. Try to add both the client's and the server's IP address to the server's hosts file.

If you run Django on *nix, it's the /etc/hosts file. If run it on MS Windows, it's the %WINDIR%\SYSTEM32\DRIVERS\ETC\HOSTS file. (They are text files and can be edited by your favourite text editor.)

ΤΖΩΤΖΙΟΥ
5 second delay always sounds like name resolving issue to me.
Ali A
+1  A: 

And if all else fails, you can always cProfile your application and see where exactly is the bottleneck.

Mosor
+8  A: 

Firefox has a problem browsing to localhost on some Windows machines. You can solve it by switching off ipv6, which isn't really recommended. Using 127.0.0.1 directly is another way round the problem.

fuzzyman
Even when localhost is in the hosts file? Interesting...
R. Bemrose
Nice info, fuzzyman!
ΤΖΩΤΖΙΟΥ
Same problem and solution under Chrome under Windows 7.
Kalmi
+1  A: 

I have had the same problem in the past. It can be solved by removing the following line from your hosts file.

::1         localhost

Once that's gone you should be able to use localhost again, quickly.

Ty
A: 

Nice. I had the same problem, that the django development server was so extremly slow. Just started with manage.py runserver 127.0.0.1:8000 and it works fine and quick. Thanks guys

Toni
+1  A: 

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.

Dylan Bauer
A: 

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

Include pattern : http://localhost*
Redirect to     : http://127.0.0.1$1

Leave the other fields empty.

westmark