[mod_python] memory usage

Yuri Ushakov yuri.ushakov at gmail.com
Sat Nov 27 13:34:48 EST 2004


Hello,

I've been running mod_python and found some difficulties.. I run
openload which does 50 concurrent connections to a test script (S1)
and within a few seconds memory obtained by the child apache process
grows from ~10mb to 215mb, and keeps growing...

S1:
from mod_python import apache

def handler(req):
    req.content_type = "text/html"
    req.write("Hello!")
    return apache.OK

Configuration:
Apache/2.0.52 (Win32) PHP/4.3.9 mod_python/3.1.3 Python/2.3.4
Python debug is off
The S1 script is configured as PythonHandler wiht no other M.P. directives.


When I try the same openload test on a different script (S2), the
process rapidly grows to ~120mb and almost stops there, continuing to
eat about 5k like each 10-20 seconds. Within about 200000 requests (50
per second), memory grew from 120 to 130 megabytes. If I turn on
PythonDebug, this growth step is much higher.

Then after stopping the testing memory does not get freed. So, after
like 20 minutes of idleness apache process still occupies the big size
(130, 215, whatever it was..).

I've been wondering whether such behaviour is caused by
misconfiguration of the apache server? Or should that memory growth
stop somewhere?Thanks for any help..

S2:
import em, StringIO
import MySQLdb
from mod_python import apache
import sys
from Pool import Pool, Constructor

def index(req):
    res = {
        'visual_title': "Testing"
    }

    req.content_type = "text/html"
    
    out = StringIO.StringIO()
    try:
        interp = em.Interpreter(output = out)
        interp.file(open(req.document_root() + "/t1/cp/tpl.empy"),\
                    locals = { 'res': res })
        req.write(out.getvalue())
    finally:
        interp.shutdown()

Configuration:
The handler is standard publisher with no other M.P. directives.

Yuri.


More information about the Mod_python mailing list