[英]Django: Module not Found on Azure App Service - Azure DevOps CD
[英]Azure “App Service” - Django and SQLite
我有一個django應用程序(特別是django-rest)。 當我運行本網站的本地副本時,我的請求可以在50-400ms內處理。
接下來,我設法部署到Microsoft Azure App Service。 現在,在我可以購買的最昂貴的層級下,響應將在800-2000ms范圍內回歸。
該應用程序對sqlite數據庫進行簡單查詢。 此數據庫文件大約為30兆字節,最大的表為12000行。
我應該指出對數據庫的所有訪問權限都是只讀的,因此沒有爭用問題。
組態:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(PROJECT_ROOT, 'mydatabase.db'),
}
}
web.config中:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="WSGI_ALT_VIRTUALENV_HANDLER" value="django.core.wsgi.get_wsgi_application()" />
<add key="WSGI_ALT_VIRTUALENV_ACTIVATE_THIS" value="D:\home\site\wwwroot\env\Scripts\activate_this.py" />
<add key="WSGI_HANDLER" value="ptvs_virtualenv_proxy.get_virtualenv_handler()" />
<add key="PYTHONPATH" value="D:\home\site\wwwroot" />
<add key="DJANGO_SETTINGS_MODULE" value="myapp.settings" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<!-- Required for websockets. -->
<httpRuntime targetFramework="4.5"/>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<handlers>
<remove name="Python273_via_FastCGI" />
<add name="Python FastCGI" path="handler.fcgi" verb="*" modules="FastCgiModule" scriptProcessor="D:\Python27\python.exe|D:\Python27\Scripts\wfastcgi.py" resourceType="Unspecified" requireAccess="Script" />
</handlers>
<rewrite>
<rules>
<rule name="Static Files" stopProcessing="true">
<conditions>
<add input="true" pattern="false" />
</conditions>
</rule>
<rule name="Configure Python" stopProcessing="true">
<match url="(.*)" ignoreCase="false" />
<conditions>
<add input="{REQUEST_URI}" pattern="^/static/.*" ignoreCase="true" negate="true" />
</conditions>
<action type="Rewrite" url="handler.fcgi/{R:1}" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Python版本2.7。
我已將其縮小到SQLite性能。 靜態文件和API索引頁面會在~60ms內返回,而最重的查詢會在~2000ms內返回。 這是Time Till First Byte,而不是整體響應時間,我已經排除了網絡延遲(由於地理位置接近而導致網絡延遲非常低)。 這是在P3(Premium Tier)4核,7GB內存(Azure稱之為)。
在localhost上運行,索引頁的響應時間約為15ms,而我的Macbook 2.2 GHz Intel Core i7 16 GB 1600 MHz DDR3上的響應時間約為380ms。
應用程序“熱身”不是問題,因為這是在它已經“熱”之后(時間基於一些刷新)
更新:我安裝了Django Rest Toolbar以獲取更多信息。
在macbook django DEV服務器(純python?):
SQL time ~217ms
Total CPU time ~681ms
Resource Value
User CPU time 662.771 msec
System CPU time 18.415 msec
Total CPU time 681.186 msec
Elapsed time 681.326 msec
Context switches 1 voluntary, 95 involuntary
在Azure應用服務IIS和FastCGI上(參見上面的配置):
SQL time ~854ms
Total CPU time ~2282ms
No CPU extended breakdown available.
欣賞任何見解!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.