PlacidLush
PlacidLush

Reputation: 444

Django App is laggy when Apache2 is used vice development server

The setup is:

  1. Windows XP VM (Stuck with this for the time being - we're on an Intranet)
  2. Apache 2,
  3. mod_wsgi
  4. django 1.4
  5. virtualenv
  6. We only have two users at most using this application simultaneously

Everything works but there is significant delay (10-20 seconds) between the browser's request and the response sent back by the server.

If I replace the Apache2 web server with the Django development server (which I do not want to do in production) the app is very responsive. So my assumption is that the problem is with Apache2 configuration or mod_wsgi configuration.

I am not an Apache expert and have spent hours looking for the right settings to configure the Apache2 web server but have failed to find anything that will improve the response.

Any assistance would be greatly appreciated.

Here are the settings that I have either changed or added to my httpd.conf:

# ThreadsPerChild: constant number of worker threads in the server process
ThreadsPerChild 10
# Changed MaxRequestsPerChild 0 to 1 for Django
MaxRequestsPerChild  1
# For Django KeepAlive should be OFF
KeepAlive Off

WSGIApplicationGroup %{GLOBAL}
#######################################
WSGIScriptAlias / "C:/virtual_env/sitar_env2/cissimp/cissimp/wsgi.py"
WSGIPythonPath C:/virtual_env/sitar_env2/Lib/site-packages;C:/virtual_env/sitar_env2/cissimp
Alias /static "C:/virtual_env/sitar_env2/cissimp/cissimp/static"
<Directory "C:/virtual_env/sitar_env2/cissimp/cissimp">
<Files wsgi.py>
Order allow,deny
Allow from all
</Files>
</Directory>
##########################################

Upvotes: 0

Views: 88

Answers (1)

Graham Dumpleton
Graham Dumpleton

Reputation: 58533

Dont set:

MaxRequestsPerChild  1

You are effectively restarting Apache on every request which means having to load the whole Django application on every request. You should not do that.

Upvotes: 1

Related Questions