Mapping different URLs to different mod_wsgi processes running the same code

20 views
Skip to first unread message

Lisper

unread,
Sep 21, 2011, 2:19:12 AM9/21/11
to mod...@googlegroups.com
I would like to run multiple instances of a single wsgi application and map those instances to different URLs on the same virtual server.  Is that possible?  How do you do it?  I tried this:

  WSGIDaemonProcess app1
  WSGIApplicationGroup app1
  WSGIProcessGroup app1
  WSGIScriptAlias /app1 /path/to/driver.wsgi

  WSGIDaemonProcess app2
  WSGIApplicationGroup app2
  WSGIProcessGroup app2
  WSGIScriptAlias /app2 /path/to/driver.wsgi

but that didn't work.  I need each URL to to map onto a single distinct Python process.  The above (apparently) mapped both /app1 and /app2 onto the same process.

Thanks!

Graham Dumpleton

unread,
Sep 21, 2011, 2:26:42 AM9/21/11
to mod...@googlegroups.com
The WSGIProcessGroup needs to be scoped else the last takes
precedence. The WSGIApplicationGroup directive wasn't required, but
since having each in its own daemon process group you are better off
them using the main interpreter of the respective processes.

WSGIDaemonProcess app1
WSGIDaemonProcess app2

WSGIScriptAlias /app1 /path/to/driver.wsgi

<Location /app1>
WSGIProcessGroup app1
WSGIApplicationGroup %{GLOBAL}
</Location>

WSGIScriptAlias /app2 /path/to/driver.wsgi

<Location /app2>
WSGIProcessGroup app2
WSGIApplicationGroup %{GLOBAL}
</Location>

Graham

> --
> You received this message because you are subscribed to the Google Groups
> "modwsgi" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/modwsgi/-/18knNcIADd4J.
> To post to this group, send email to mod...@googlegroups.com.
> To unsubscribe from this group, send email to
> modwsgi+u...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/modwsgi?hl=en.
>

Lisper

unread,
Sep 21, 2011, 1:06:40 PM9/21/11
to mod...@googlegroups.com
That works.  Thanks!

Lisper

unread,
Sep 21, 2011, 1:54:08 PM9/21/11
to mod...@googlegroups.com
I'm still confused about something:  The configuration above gives me multiple Python sub-interpreters all running in the same unix process (presumably the main Apache process?)  But what I really want (I think) is multiple pythons each running in their own process so that they can run in parallel.  I can get this by changing WSGIApplicationGroup %{GLOBAL} to WSGIApplicationGroup appX.  Is that right?  And is there a reason you recommended the single-process configuration?

Graham Dumpleton

unread,
Sep 21, 2011, 5:18:02 PM9/21/11
to mod...@googlegroups.com

WSGIProcessGroup is for processes. WSGIApplicationGroup specifies the
embedded sub interpreter within the process. Don't equate interpreter
with having a process of its own.

So that configuration specified two separate processes, distinct from
Apache processes, with each application running separately. When run
up in their distinct processes they ran in the first interpreter
created when embedded Python was initialised.

So yes, you are a bit confused. :-)

Read:

http://code.google.com/p/modwsgi/wiki/ProcessesAndThreading
http://code.google.com/p/modwsgi/wiki/CheckingYourInstallation#Embedded_Or_Daemon_Mode
http://code.google.com/p/modwsgi/wiki/CheckingYourInstallation#Sub_Interpreter_Being_Used
http://code.google.com/p/modwsgi/wiki/CheckingYourInstallation#Single_Or_Multi_Threaded

See also the display-name option to WSGIDaemonProcess so you can name
the processes and distinguish them in 'ps' output.

http://code.google.com/p/modwsgi/wiki/ConfigurationDirectives#WSGIDaemonProcess

Graham


> --
> You received this message because you are subscribed to the Google Groups
> "modwsgi" group.
> To view this discussion on the web visit

> https://groups.google.com/d/msg/modwsgi/-/0-j7tSo5n9wJ.

Reply all
Reply to author
Forward
0 new messages