WSGIDaemonProcess for each application instance

apache-2.2daemonwsgi

I'm using Apache & mod_wsgi to deploy a django application on several servers. I've read in multiple places (including this: http://blog.dscpl.com.au/2012/10/why-are-you-using-embedded-mode-of.html) that it's better to use the Daemon mode of wsgi. This would allow me to have control over process count and thread count per process, among other neat things 🙂

Now my is that I can have two or more instances of my django application on the same server (with each its own settings, databases, etc). For example:

  • http://team1-server/prod-instance
  • http://team1-server/test-instance

Tough I think I understand how to use a different "process group" and "daemon process" configuration for multiple virtualhosts, i don't seem to wrap my mind around what i should do with multiple "sub-roots".

EDIT:

I run those under CentOS 6.2 distros. In the /etc/httpd/conf.d/ directory I have one .conf file for each instance which looks like this:

WSGIScriptAlias /prod-instance /opt/wsgi_applications/prod/app.wsgi

END EDIT.

Should I use virtualhosts and have urls such as http://prod-instance.team1-server/ instead? That would mean I should rely on the network managers to update the DNS tables, which is never fast enough for our clients. 🙂

I must admit I'm often lost when it comes to Apache configuration. Your help is welcome.

Thanks!

O.

Best Answer

Presuming you are not using a very old obsolete mod_wsgi version, you can say:

WSGIDaemonProcess prod-instance
WSGIScriptAlias /prod-instance /opt/wsgi_applications/prod/app.wsgi process-group=prod-instance application-group=%{GLOBAL}

WSGIDaemonProcess test-instance
WSGIScriptAlias /test-instance /opt/wsgi_applications/test/app.wsgi process-group=test-instance application-group=%{GLOBAL}

If you are using a very old obsolete mod_wsgi version, instead use:

WSGIDaemonProcess prod-instance
WSGIScriptAlias /prod-instance /opt/wsgi_applications/prod/app.wsgi
<Location /prod-instance>
WSGIProcessGroup prod-instance
WSGIApplicationGroup %{GLOBAL}
</Location>

WSGIDaemonProcess test-instance
WSGIScriptAlias /test-instance /opt/wsgi_applications/test/app.wsgi
<Location /test-instance>
WSGIProcessGroup test-instance
WSGIApplicationGroup %{GLOBAL}
</Location>