[Web-SIG] multi-threaded or multi-process wsgi apps

Chris Withers chris at simplistix.co.uk
Fri Nov 30 00:16:07 CET 2007

Graham Dumpleton wrote:
> package. You can if appropriate even use a combination of both modes.

So these would just be seperate sections in apache's config files?

> For example, run Django in embedded mode for best performance, 

Why does this give best performance?

> but
> delegate a Trac instance to run in daemon mode so it is separated out
> of Apache child processes, there being various reasons with Trac why
> you might want to do that.

Such as?

> Each process can if necessary have multiple Python sub interpreters,
> and is not limited to just one. This would be used where you need to
> run multiple applications in the same process but with sub
> interpreters being used as a means of separating them so they don't
> interfere with each other.

Wow, I didn't even know this was possible.. what does 
dirt-simple-hello-world-like python that does this look like?

>> (ie: does it have to reload all its config and open up its own database
>> connections again?)
> Being separate processes then obviously they would need to do that.
> This is generally no different to how people often run multiple
> instances of a standalone Python web based application and then use a
> proxy/load balancer to distribute requests across the processes.


The difficulty comes when you have to invalidate changes across 
processes. ZEO/ZODB is the only object system I know that does that.
If you were using a relational database and/or a mapper such as 
SQLAlchemy, I wonder how you could poke it such that config-like changes 
in one process were propogated to another. That said, I wonder how 
SQLAlchemy handles invalidations of its object model when the underlying 
database changes as a result of actions by another process...
...but this is the wrong list for that.

> Thus generally better for each process to create its own connections
> etc. Reading of actual file configuration is generally a quite minor
> overhead in the greater scheme of things.

You haven't used zope, right? ;-)



Simplistix - Content Management, Zope & Python Consulting
            - http://www.simplistix.co.uk

More information about the Web-SIG mailing list