best way to serve wsgi with multiple processes

Robin Becker robin at reportlab.com
Wed Feb 11 10:46:45 EST 2009


Robin wrote:
..........
> 
> Yes - I've done something very similar with ajp-wsgi (from the author
> of flup; and which incidently performs very well works really nicely)
> to go from apache -> wsgi. But the issue I'm asking about here is to
> have multiple WSGI processes - ie to allow concurrent execution of
> more than one web service at the time (since these are long running
> computational soap web services). ajp-wsgi embeds a single python
> interpreter so multiple running services would be effected by the GIL
> - I imagine flup is similar (a single process on the python side).
> 
> So I'm not worried about decoupling from the web server - I'm happy to
> use pure python server (which I guess is easier to setup) - but I want
> the web server to dispatch requests to different processes running the
> wsgi app. I've looked at Spawning, but couldn't get it to work and it
> seems a little bit 'beta' for my taste (doesn't exit cleanly, leaves
> worker processes running etc.)

well the flup server for fast cgi supports forking if the server is declared as 
an external process in apache. Then the top level of the flup process handles 
each request and passes it off to a forked worker. I cannot recall exactly, but 
I believe that apache mod_fastcgi does the right thing when it comes to 
internally declared fastcgi handlers. For apache at least I think the threading 
issues are handled properly.

I think the preforkserver.py code handles all the threading issues for you 
(assuming it's not win32).
-- 
Robin Becker




More information about the Python-list mailing list