[mod_python] Mod_python and Sub-Interpreter segregation

Martin Pool mbp at samba.org
Wed Sep 25 18:33:50 EST 2002

On 17 Sep 2002, Bryan Mongeau <bryan at eevolved.com> wrote:
> On September 14, 2002 03:07 am, Michael Neel wrote:
> > Thank will work great, until you hit the 65th concurrent connection, at
> > wich point apache will give you another child.
> Thanks Mike. It seems as if even when MaxClients is set to 64 apache will fork 
> another child anyway on the 65th concurrent connection... Why? Do you know 
> what is going on here? I would like to simply work around the issue by 
> limiting the amount of concurrent clients.

I think if you go down the path of relying on data kept inside an
Apache instance you will regret it.  The right way to retain state on
the server is to keep it in some kind of external database. 

Here are a few reasons:

 - If you reconfigure apache (e.g. apachectl graceful) or need to
   restart it, the data in memory will be irretrievably lost.
   Perhaps at the moment you don't need strong persistence but most
   web apps find their storage needs grow, so you will in the future. 

 - Having multiple children is an important robustness feature of

 - Keeping shared data separate is a "safer" design -- if you need to  
   coordinate access between threads then there is a risk of race
   conditions or lockups.  For example, if one thread abnormally
   terminates, it might leave internal data structures in an
   inconsistent state.  If you use an external database things are
   more isolated and easier to debug.

 - Using something like Python's shelve module is nearly as easy as an
   in-memory variable.

This is a dead horse; there are plenty of other discussions of it on
the web.  Don't repeat mistakes that were learnt by others six years


More information about the Mod_python mailing list