[mod_python] Performance Problem

Graham Dumpleton grahamd at dscpl.com.au
Sat Aug 20 06:05:46 EDT 2005

Sebastjan Trepca wrote ..
> 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?

In general it means that within a specific Apache child subprocess, that
no matter what the URL, or the virtual host they are directed to, all
the requests will be handled by Python code executing within one Python
interpreter instance. Note that I said "within a specific Apache child
subprocess". You can't change the fact that on UNIX, each subprocess has
its own memory and thus even if there are interpreters with the same
name in each, they have distinct copies of data.

For most installations of Apache/mod_python this would be the case
anyway regardless of whether you set PythonInterpreter. This is because
mod_python creates a default interpreter instance with name
corresponding to the virtual host name, ie. the name of the web site.
Since most sites go by one name, there will thus only be one interpreter,
unless specific action is taken by setting PythonInterpreter,
PythonInterpPerDirective, or PythonInterpPerDirectory to create
additional interpreters for some subset of the URL namespace.

The purpose of PythonInterpreter is thus for where a server might host
multiple virtual hosts and instead of requests for each virtual host being
handled in separate interpreters, you want to force them all to be handled
in the same interpreter.

In summary, it doesn't at all cause different Apache child subprocesses
to somehow magically start sharing data.


More information about the Mod_python mailing list