Sunday, March 3, 2013

Speeding Up Django on Webfaction

My Django/mod_wsgi site uses virtualenv and uses the apache directive VirtualHost. Thus the standard install files, such as httpd.conf, provided by Webfaction need modification. 

The problem I encountered was the first page hit to the server would take more than 10 seconds to load. Subsequent pages would load quickly. The Chrome auditing functionality, showed that these long load times mostly involve the browser waiting for the server after the initial http request.

Others have seen this phenomena. For me, the most useful part of this forum post was introduction to the ab tool. This tool helped me improve my httpd.conf file.

Some strangeness. The ab function continues to work and have good performance even after the server is stopped!

Chrome strangeness - I am using Version 24.0.1312.56 Ubuntu 12.04 (24.0.1312.56-0ubuntu0.12.04.1) on Linux and Version 25.0.1364.152 on Mac OS 10.7.5  I am using the developer tools on both. The network tab shows a timeline of the loading of each component of the page. I expect a bunch of my static files to be retrieved from the browser cache. Both browsers show an http status code of 200 for items that should be retrieved from cache. On the Mac the load times of those files is 0, and the page loads fast. On Linux, the page loads much slower and the load times for those components are on the order of seconds. Firefox on Ubuntu loads extremely fast and indicates it is getting those files from cache.


No comments:

Post a Comment