[mod_python] Performance Problem

Sebastjan Trepca trepca at gmail.com
Sat Aug 20 05:43:04 EDT 2005


Thanks for reply, I read the docs again and got this on the
PythonInterpreter directive:

"This directive can be used to force execution that would normally
occur in different subinterpreters to run in the same one. When
specified in the DocumentRoot, it forces the whole server to run in
one subinterpreter."

What does "forces whole server to run in one subinterpreter" then mean?

Sebastjan

On 20/08/05, Graham Dumpleton <grahamd at dscpl.com.au> wrote:
> Sebastjan Trepca wrote ..
> > > From: "Graham Dumpleton" <grahamd at dscpl.com.au>
> > > To: Julien <jcigar at ulb.ac.be>
> > > Date: Thu, 18 Aug 2005 18:18:44 -0400
> > > Subject: Re: [mod_python] Performance Problem
> > > Julien wrote ..
> > > > I don't think it's possible (not sure) because mod_python starts many
> > > > python instances, so mod_python cannot keep python objects ...
> > >
> > > This is not strictly true.
> > >
> > > For any particular Python interpreter, that is generally 1 per process,
> > > the modules once loaded into the interpreter will remain loaded. The
> > > value of any global data within a specific module is thus retained
> > > between requests which hit that specific interpreter.
> > >
> > > Obviously, different interpreters will have their own copy of the data
> > > value, but at least for the one interpreter, successive requests can
> > > make use of any cached data. As mentioned by Mike, this cached
> > > data could be a database connection pool.
> > >
> > > Graham
> >
> > I use only one interpreter using PythonInterprete option so different
> > processes have same globals. Are there any performance issues with
> > this?
> 
> It doesn't matter if you name the interpreter using PythonInterpreter,
> each process will still has a unique instance of the interpreter with
> that name, each with its own unique copies of the globals. Different
> processes can never reference the same globals. Changing a global in
> one process will not cause a global of the same name in a module to
> be changed in other processes.
> 
> The only time a request handler will see a change made to a global by
> a different request hander is when the two requests were against the
> same interpreter within the same process.
> 
> Thus a global data value accessed in a module is exactly the same as if
> you were running a Python script from the command line, there is no
> additional overhead and no performance issues to worry about.
> 
> If you want to have some special data value which can be accessed by
> multiple Apache child processes, with each being able to change the
> data and the change being reflected in all, then you would need to use
> something like shared memory. This would involve some extra overhead,
> but it requires you to explicitly code your system to use shared memory
> and dea with all the locking and contention issues, it isn't how
> mod_python works normally.
> 
> Use of shared memory is an advanced topic and I wouldn't recommend
> you contemplate it until you understood quiet well how mod_python
> works.
> 
> Graham
> 
> 
>



More information about the Mod_python mailing list