[mod_python] Multiple Interpreters mod_python optimization

Graham Dumpleton graham.dumpleton at gmail.com
Sat May 16 07:11:56 EDT 2009


I'd be doing a really thorough check of your Apache configuration
files to double check that you don't have MaxRequestPerChild set in an
unlikely spot somewhere with it set to 1. You may have done this to
force source code reloading on every request and forgotten about it.

Beyond that, I would start dumping out os.getppid() and verify that
the parent process is actually the main Apache parent/monitor process
for the instance you are seeing run by 'ps'.

Also use the 'mod_python.apache.mpm_query()' function to find out
value of AP_MPMQ_MAX_REQUESTS_DAEMON. See:

  http://www.modpython.org/live/current/doc-html/pyapi-apmeth.html

Also diligently check your Apache error log files for instances of
Segmentation Fault messages. Plus also pay close attention to those
messages from mod_python about when source code is being reloaded,
ie., into what process (pid) and what sub interpreter.

Graham

2009/5/15 zsi <zsi at skolesys.dk>:
>
>
> 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
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python
>



More information about the Mod_python mailing list