I have a django application (specifically django-rest). When I run a local copy of this site, my requests can be processed in 50-400 ms.
Then I managed to deploy the Microsoft Azure App Service. Now, with the most expensive tier that I can buy, the responses are returned in the range of 800-2000ms.
The application performs simple queries in the sqlite database. This database file is about 30 megabytes and the largest table is 12,000 rows.
I must indicate that access to the database is read-only, so no competition problems.
Configuration:
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" /> <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 version 2.7.
I narrowed it down to SQLite performance. Static files and API index pages are returned in ~ 60 ms, and the heaviest request is in ~ 2000 ms. This is the time before the first byte, and not the total response time, and I excluded network latency (which is very small due to geographical proximity). This refers to the 4-core core P3 (Premium Tier), 7 GB (what is his name Azure).
Running on the local host, the response time is ~ 15 ms for index pages and ~ 380 ms for the same requests on my Macbook 2.2 GHz Intel Core i7 16 GB 1600 MHz DDR3.
"Warming up" the application is not a problem, as it happens after it is already "hot" (time based on several updates)
Update: I installed the Django Rest toolbar for more details.
On macbook django dev server (pure 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
In the azure service for IIS and FastCGI applications (see configuration above):
SQL time ~854ms Total CPU time ~2282ms No CPU extended breakdown available.
Appreciate any understanding!