2013-04-08 38 views
0

的設置是:Django應用程序是laggy

  1. 的Windows XP虛擬機(與此卡住暫時 - 我們的Intranet上)
  2. 的Apache 2,
  3. mod_wsgi的
  4. 的Django 1.4
  5. 的virtualenv
  6. 我們只有兩個用戶最多同時使用這個應用程序

一切正常,但瀏覽器的請求和服務器發回的響應之間存在顯着的延遲(10-20秒)。

如果我用Django開發服務器(我不想在生產中執行)替換Apache2 Web服務器,該應用程序的響應速度非常快。所以我的假設是,問題是Apache2配置或mod_wsgi配置。

我不是Apache專家,花了數小時尋找正確的設置來配置Apache2 Web服務器,但未能找到任何可以改善響應的東西。

任何援助將不勝感激。

這裏是我要麼更改或添加到我的httpd.conf的設置:

# ThreadsPerChild: constant number of worker threads in the server process 
ThreadsPerChild 10 
# Changed MaxRequestsPerChild 0 to 1 for Django 
MaxRequestsPerChild 1 
# For Django KeepAlive should be OFF 
KeepAlive Off 

WSGIApplicationGroup %{GLOBAL} 
####################################### 
WSGIScriptAlias/"C:/virtual_env/sitar_env2/cissimp/cissimp/wsgi.py" 
WSGIPythonPath C:/virtual_env/sitar_env2/Lib/site-packages;C:/virtual_env/sitar_env2/cissimp 
Alias /static "C:/virtual_env/sitar_env2/cissimp/cissimp/static" 
<Directory "C:/virtual_env/sitar_env2/cissimp/cissimp"> 
<Files wsgi.py> 
Order allow,deny 
Allow from all 
</Files> 
</Directory> 
########################################## 
+0

這裏有很多可能的問題,但常見的問題是一些名稱解析問題。你有沒有嘗試設置ServerName apache指令?從服務器機器訪問Web應用程序時是否發生問題?從另一個?從兩個? – niconoe 2013-04-08 15:52:44

回答

1

不要設置:

MaxRequestsPerChild 1 

您在這意味着不必每個請求有效地重啓動Apache在每個請求中加載整個Django應用程序。你不應該那樣做。

+0

從我讀到的這是Django推薦的設置。你在暗示這是因爲我使用的是Windows嗎?你能推薦適當的設置嗎? – PlacidLush 2013-04-09 11:18:07

+0

將MaxRequestsPerChild設置爲1絕對不是Apache推薦的設置。即使對於開發,它也不是一個好主意。你在讀什麼,說這樣做。閱讀http://blog.dscpl.com.au/2008/12/using-modwsgi-when-developing-django.html http://blog.dscpl.com.au/2009/02/source-code-reloading- with-modwsgi-on.html http://code.google.com/p/modwsgi/wiki/ReloadingSourceCode – 2013-04-09 23:15:59

+0

非常感謝格雷厄姆。我查看了您的博客,並將MaxRequestsPerChild設置爲0,並且性能真正提升。該設置是Django文檔中mod_python建議配置的延期。 – PlacidLush 2013-04-10 11:38:24