[mod_python] modpython, mysqldb best paractice

Jim Gallacher jpg at jgassociates.ca
Wed Jul 19 17:32:31 EDT 2006

Martijn Moeling wrote:
> Deron Meranda wrote:
>> Perhaps you've got some suboptimal SQL.  For instance are you
>> doing a lot of sorts, or very large joins?
>> Also what MySQL storage engine are you using?  InnoDB, or
>> MyISAM, etc?
> Also, I'm not sure if you told us anything about your OS, apache version
> and mpm (prefork or worker) or mod_python version.
> The fact is the mod_python has memory leaks. We are tracking them down -
> 3.2.8 is better than 3.1.4, and the next stable release will be better
> yet. (Fixed a leak util.parse_qsl used in FieldStorage). Having
> mod_python leak memory could impact mysql, causing heavy swapping when
> trying to build a query result. Just a WAG and another thing to
> consider.
> Jim
> -----------------------------
> Thanx Jim, I did not know about the memory leaks, But you have a point
> on the mysql behaviour, one of the implications of my system is lots of
> queries
> so the memory hunger of mysql seems justified.
> I think I have mod_python 3.2.8, I will have a look
> Considering memory leaks, do you think, altering the minserver,
> maxserver, spare and alike parameters configuring apache, If there are
> memory leaks killing the app in some automatic way does not clog up log
> files etc. I rather have the overhead of process creation than then a
> down server when I am windsurfing.  

I don't want to give the wrong impression. I'm not certain that you
*are* experiencing mod_python memory leaks, just that it is one
possibility. You may not experience any leaks at all - it just depends
on whether your code uses any of the leaky bits (and of course your
mod_python version). However in the interest of helping you relax and
enjoy your windsurfing, I'd set a value for MaxRequestsPerChild.
Something like 10000 might be a good starting point.

If you are otherwise happy with your performance then I'd leave the
other parameters as is.

Of course you are not managing it if you aren't measuring it, so you
should actually check and see if Apache / mod_python *is* leaking. I
find top in batch mode handy for this sort of thing.

top -b -u www-data -n 1 | grep apache2 >> mem.log

Stick this in a cron job and see if there is an upward trend in memory


More information about the Mod_python mailing list