[mod_python] Multiple Interpreters mod_python optimization

zsi zsi at skolesys.dk
Fri May 15 08:24:40 EDT 2009



On Fri, 15 May 2009 21:40:46 +1000, Graham Dumpleton
<graham.dumpleton at gmail.com> wrote:
> 2009/5/15 zsi <zsi at skolesys.dk>:
>> On Fri, 15 May 2009 20:35:59 +1000, Graham Dumpleton
>> <graham.dumpleton at gmail.com> wrote:
>>>>> BTW, the process IDs in your 'ps' output don't even match what your
>>>>> Python code is producing. Looks like you aren't even talking to the
>>>>> same Apache instance.
>>>> I wasn't expecting them to match. The process id's from the python
code
>>>> are the interpreter's pid not the apaches. What I wanted to show by
>>>> that was that it is stille the same apache processes (8 of them) but
>>>> I have 18 different interpreter process ID's. So it is not because I
>>>> hit a new apache process every time.
>>>
>>> Did you read the document I told you to read about process/interpreter
>>> model of Apache/mod_python? As well as the blog entry?
>>>
>>> The Python sub interpreters run in the Apache child processes. Thus
>>> the process IDs from your Python code must have some overlap with the
>>> Apache processes you listed.
>>>
>>> Apache/mod_python does not create special Python interpreter processes.
>>
>> Yes, I read it and it makes it even more odd that I get a new pid
> everytime
>> I call os.getpid(), that doesn't match the apache processes.
> 
> Have you run 'ps' to find out what processes are using those pids and
> whether they exist after the requests are done.
> 
> If need be, put a time.sleep() call after you log the pid to give you
> time to do the 'ps', just in case they are transient as a result of
> Apache configuration, or because they are crashing at end of request.
> 
> Also ensure you have set:
> 
>   PythonDebug On
> 
> to enabled stuff in Apache error logs about mod_python loading of files.

That was a very good idea, and you are right it is apache processes, just
not the ones started initially by the main apache process. So I guess the
question is what I did wrong in the apache configuration since new apache
servers are spawned each time a request comes in - and terminated right
away. Of course I know this will happen as the load increases (if I don't
change the Min/MaxSpareServers) but why doesn't it use the ones already
there before starting new ones?

May 15 14:08:55 capa-server capa: REQUESTINFO: ps aux|grep pid   = capa
8981  0.0  2.3  20288 11972 ? S 14:08 0:00 /usr/sbin/apache2 -k start 
May 15 14:08:55 capa-server capa: REQUESTINFO: Interpreter Name  =
/srv/capa/www/0.9/sessionservice/
May 15 14:08:55 capa-server capa: REQUESTINFO: os.getpid()       = 8982
May 15 14:08:55 capa-server capa: REQUESTINFO: ps aux|grep pid   = capa
8982 66.0  2.2  20288 11844 ? S 14:08 0:00 /usr/sbin/apache2 -k start 
May 15 14:08:56 capa-server capa: REQUESTINFO: Interpreter Name  =
/srv/capa/www/0.9/sessionservice/
May 15 14:08:56 capa-server capa: REQUESTINFO: os.getpid()       = 8987
May 15 14:08:56 capa-server capa: REQUESTINFO: ps aux|grep pid   = capa
8987 78.0  2.5  20808 13028 ? S 14:08 0:00 /usr/sbin/apache2 -k start 
May 15 14:08:57 capa-server capa: REQUESTINFO: Interpreter Name  =
/srv/capa/www/0.9/sessionservice/
May 15 14:08:57 capa-server capa: REQUESTINFO: os.getpid()       = 8997
May 15 14:08:57 capa-server capa: REQUESTINFO: ps aux|grep pid   = capa
8997 74.0  2.3  20288 11972 ? S 14:08 0:00 /usr/sbin/apache2 -k start

Best regards
Jakob Simon-Gaarde


More information about the Mod_python mailing list