I have a single Django-project on standard webfaction plan (256mb ram). The average loading time of my website is about 4 seconds. I configured most of the performance tweaks regarding Django (caching, compression, serving static files …). So I’m only interested in improvements of the Apache configuration. Is 4 sec loading time on a website with 200kb of data, needing about 15 request to load, the limit with webfaction or can I improve this significantly? This is what my httpd.conf looks like right now:
ServerRoot "/home/XXXXXX/webapps/XXXXXX/apache2"
LoadModule dir_module modules/mod_dir.so
LoadModule env_module modules/mod_env.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule mime_module modules/mod_mime.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule wsgi_module modules/mod_wsgi.so
#LoadModule headers_module modules/mod_headers.so
LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
KeepAlive Off
Listen 28010
MaxSpareThreads 3
MinSpareThreads 1
ServerLimit 1
SetEnvIf X-Forwarded-SSL on HTTPS=1
ThreadsPerChild 15
WSGIDaemonProcess XXXX processes=15 python-path=/.../lib/python2.6 threads=8
WSGIPythonPath /home/XXXX/webapps/XXXXX:/home/XXXX/webapps/XXXXXX/lib/python2.6
WSGIScriptAlias / /home/XXXXXX/webapps/XXXXXX/XXXXXX.wsgi
Does something like KeepAlive On increase the performance?
Thanks in advance horndash
No, no, no. KeepAlive and Django do not play well together. To quote from the Django book here:
Turn off Keep-Alive
Keep-alive is a feature of HTTP that allows multiple HTTP requests to be served over a single TCP connection, avoiding the TCP setup/teardown overhead.
This sounds good at first glance, but can actually kill performance of a Django site. If you’re properly serving media from a separate server, each user browsing your site will actually only a page from your Django server every 10 seconds at best. This leaves HTTP servers waiting around for the next keep-alive request, and a idle HTTP server just consumes RAM that an active one should be using.