django 在我的机器上很慢 [英] django is very slow on my machine

查看:51
本文介绍了django 在我的机器上很慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我全新安装了 django 1.0,加载一个简单的页面需要 5 秒.在我同事的电脑上几乎不需要时间.

我使用

启动服务器<前>python manage.py testserver

我可以看到每个 GET 请求(PNG 和样式表)大约需要半秒钟.

另一个奇怪的事情,我认为是相关的,是应用程序的功能测试在我使用 MySQL 的机器上运行得慢得多(比我同事的机器慢 100 倍).当我将应用程序设置为使用 sqlite 时,它​​们运行得非常快.我想说,sqlite 并没有改变加载页面所需的时间,但它确实加快了服务器启动速度.

看起来像是 IO 问题,但我的机器上没有看到一般的性能问题,至少除了 django.

Django 在 python2.4 上运行,我运行的是 Vista.我也查过python2.5.

谢谢 ΤΖΩΤΖΙΟΥ,这一定是 DNS 问题,因为页面加载很快而不是 http://localhost:8000/app 我去 http://127.0.0.1:8000/app.

但这可能是由什么引起的?我的主机文件只有两个条目:

<前>127.0.0.1 本地主机::1 本地主机

解决方案

Firefox 在某些 Windows 机器上浏览本地主机时出现问题.您可以通过关闭 ipv6 来解决它,这不是真正推荐的.直接使用 127.0.0.1 是另一种解决问题的方法.

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

解决方案

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.

这篇关于django 在我的机器上很慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆