Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am new to Django/Python/ mod_wsgi, and I was wondering if I could optimize this file to reduce memory usage:

ServerRoot "/home/<foo>/webapps/django_wsgi/apache2"

LoadModule dir_module        modules/
LoadModule env_module        modules/
LoadModule log_config_module modules/
LoadModule mime_module       modules/
LoadModule rewrite_module    modules/
LoadModule setenvif_module   modules/
LoadModule wsgi_module       modules/

LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
CustomLog /home/<foo>/logs/user/access_django_wsgi.log combined
ErrorLog /home/<foo>/logs/user/error_django_wsgi.log
KeepAlive Off
Listen 12345
MaxSpareThreads 3
MinSpareThreads 1
MaxClients 5
MaxRequestsPerChild 300
ServerLimit 4
HostnameLookups Off
SetEnvIf X-Forwarded-SSL on HTTPS=1
ThreadsPerChild 5
WSGIDaemonProcess django_wsgi processes=5 python-path=/home/<foo>/webapps/django_wsgi:/home/<foo>/webapps/django_wsgi/lib/python2.6 threads=1
WSGIPythonPath /home/<foo>/webapps/django_wsgi:/home/<foo>/webapps/django_wsgi/lib/python2.6
WSGIScriptAlias /auctions /home/<foo>/webapps/django_wsgi/auctions.wsgi
WSGIScriptAlias /achievers /home/<foo>/webapps/django_wsgi/achievers.wsgi
share|improve this question

Although you have defined WSGIDaemonProcess directive to create a separate daemon process group, you aren't actually using it. If it is your intention to use daemon mode, you should delete WSGIPythonPath and add instead:

WSGIProcessGroup django_wsgi

Also, if you are going to use daemon mode and the only thing occurring in main Apache processes is serving static files, you can change ThreadsPerChild back to:

MaxRequestsPerChild 0

as there is no need to be recycling the Apache server child processes on a periodic basis.

BTW, it is bad practice to throw away the complete default Apache configuration and then add in just what you think is needed. This is because you are throwing away all the default access security meaning that technically every file on your system can be served up if there is a URL mapping which exists that allows one to get to the file.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.