Partition Django site across multiple processes?

16 views
Skip to first unread message

Andy

unread,
Nov 26, 2021, 4:08:03 PM11/26/21
to modwsgi
Is it possible to partition traffic for a single Django site across multiple processes i.e. use WSGIScriptAlias to point to the same WSGI script but configure a subset of URLs to route to different processes? 

Apache virtual host configuration excerpt:

WSGIApplicationGroup api
WSGIDaemonProcess api processes=2 display-name='%{GROUP}' lang='en_US.UTF-8' locale='en_US.UTF-8'
WSGIScriptAlias /api <path>/wsgi.py process-group=api application-group=api

WSGIApplicationGroup web
WSGIDaemonProcess web processes=5 display-name='%{GROUP}' lang='en_US.UTF-8' locale='en_US.UTF-8'
WSGIScriptAlias / <path>/wsgi.py process-group=web application-group=web

When configured like this /api traffic does appear to be picked up by the correct process but fails Django URL resolution (and raises a 404).

Quite possible that this is purely a Django issue, but just want to check if this approach is feasible / advisable.

Thanks.

Graham Dumpleton

unread,
Nov 26, 2021, 4:11:10 PM11/26/21
to mod...@googlegroups.com
See explanation in this blog post.


You only want one WSGIScriptAlias mount directive and use Location to apply conditions on where traffic is directed.

Also recommended to force use of main interpreter context in each daemon process group by setting WSGIApplicationGroup to %{GLOBAL}. This avoids issues with some Python packages that will not work in sub interpreters.

Graham

--
You received this message because you are subscribed to the Google Groups "modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to modwsgi+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/modwsgi/7907f10d-c39b-48ea-81b7-0a38a9125a21n%40googlegroups.com.

Andy

unread,
Nov 29, 2021, 5:34:05 AM11/29/21
to modwsgi
Thanks - much appreciated.
Reply all
Reply to author
Forward
0 new messages