[mod_python] Re: Apache and mod_python memory usage

Graham Dumpleton grahamd at dscpl.com.au
Fri Feb 16 05:27:02 EST 2007


How big is your mod_python.so module for Apache? If Python was not built
so as to create a shared library for itself when mod_python.so is built it may
include the actual Python library itself. It is possible this shows as memory
used by process as opposed to shared memory if shared library was used.
On Mac OS X where equivalent of shared library used, Apache only consumes
a few MB of memory upon startup (from memory, can't confirm right now).
How it works on other platforms not exactly sure. If on UNIX like systems, can
run:

  ldd mod_python.so

and it will indicate whether using Python as shared library.

Graham

Eugene Morozov wrote ..
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Hello,
> No, this figure is the initial starting size and it doesn't grow at all
> with time. We currently have two virtual hosts running. I don't think
> it's really a problem, just wanted to know if such initial memory
> consumption is normal or not. Can anyone else post their figures?
> Eugene
> 
> Graham Dumpleton пишет:
> > Eugene Morozov wrote ..
> >> -----BEGIN PGP SIGNED MESSAGE-----
> >> Hash: SHA1
> >>
> >> Hello,
> >> We're using apache and mod_python for running Pylons-based CMS. We're
> a
> >> little bit concerned with memory usage. With mod_python
> >> apache2-mpm-worker consumes a lot of memory:
> >>
> >> PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
> >> 23787 www-data 20 0 366m 48m 4104 S 0.0 12.5 0:09.23 apache2
> >>
> >> 48Mb is a bit too big even for apache. And why it needs 366Mb of virtual
> >> memory?
> >>
> >> If I disable mod_python these values are cut significantly (to 266Mb
> >> virtual and 21Mb RSS, which is still much, it seems).
> >>
> >> Not that it's a huge problem now, but I'm curious why so much memory
> is
> >> consumed.
> > 
> > What are the figures immediately after Apache has started and before
> any requests
> > have been handled by mod_python? When determining this, ensure that not
> > PythonImport directives are being applied to preload/execute any Python
> code.
> > 
> > This figure will be the initial starting size with only the main Python
> interpreter
> > instance created. Beyond that, the size will grow based on what your
> own Python
> > code is doing, how many additional Python interpreter instances are created
> or
> > possibly due to memory leaks.
> > 
> > As far as memory leaks in mod_python go, ensure that you are using the
> latest
> > version of mod_python, ie., 3.3. There are memory leaks in older versions
> which
> > depending on what your code is doing may be getting triggered.
> > 
> > As to Python interpreter instances, how many virtual hosts are you running
> on
> > the server under which mod_python requests are being handled? Also, are
> you
> > using any of PythonInterpPerDirectory or PythonInterpPerDirective or
> > PythonInterpreter directives? If you are using these and depending on
> how
> > you use them, you could be unnecessarily creating additional Python interpreter
> > instances which may be unnecessarily consuming additional memory.
> > 
> > Finally, does this figure keep going up and up over time which may indicate
> > memory leaks in mod_python or your own Python code?
> > 
> 
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.3 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
> 
> iD8DBQFF1Tkak5VH2F5tiW4RAku7AKDRVyEqXh3JFyj3SCbJ40P+yirzEwCgs65e
> jDg69zy25rbK6lb/Jt8G36c=
> =23AR
> -----END PGP SIGNATURE-----
> 
> _______________________________________________
> 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