On Sep 13, 6:18 pm, omat <[EMAIL PROTECTED]> wrote: > Hi, > > This is more of a python / mod_python configuration issue, but there > had been some discussions on this list ([1]), and django-users is > where I feel home, so I am posting here. Sorry. > > I am running 7 Django sites with an Apache + mod_python setup, on a > Fedora Core 4 dedicated server with 2 GB memory. When I restart > apache, memory usage is somewhere between 200 - 400 MB and quickly > climbs up to somewhere around 1.5 GB. The sites are not high traffic, > in total, they generate no more then 20,000 page views daily. > > I am not very comfortable with linux server configuration, but with > the light of ref. [1], I did some examinations. My process list shows > that there is 1 parent (pid:2293) using 20+ MB, and 21 child apache > processes using 20-60 MB each.
Using prefork and embedded Python in Apache child processes using mod_python is not a good idea. > F UID PID PPID PRI NI VSZ RSS COMMAND > 1 0 2293 1 16 0 23840 11204 - /usr/sbin/httpd > 5 0 2300 2293 23 0 19704 4512 - /usr/sbin/httpd > 5 48 2301 2293 15 0 49844 34288 - /usr/sbin/httpd > 5 48 2302 2293 16 0 61092 45344 - /usr/sbin/httpd > ... > > Size of mod_python.so was over 4 MB, and ldd command shows no link to > libpython.so, which means that the mod_python was build with a static > library (which causes huge memory consumption) according to [1]. > > So, I started with building python2.5.1 with --enable-shared option: > $ LD_RUN_PATH=/usr/local/lib > $ export LD_RUN_PATH > $ ./configure --enable-shared > $ make > # make install > > Then I installed mod_python3.3.1: > $ ./configure --with-apxs=/usr/sbin/apxs > $ make > # make install > > Now the new mod_python.so is 3.8 MB, not 300K as promised. And ldd > still does not show any reference to libpython. And the memory > consumption follows the same pattern. Probably because the Python 'config' directory does not have the required symlink in it which points to where the shared library was installed. Ie., in 'config' directory the libpython2.5.a and libpython2.5.so must be side by side else libtool/ld will not find and use the shared library. Compiling from Python source code causes this problem, where as packaged distributions usually ensure it is done properly. What I would suggest you do is look at mod_wsgi daemon mode. See configuration examples in: http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango and for some more complicated automated hosting examples for numerous applications instances also see Trac examples in: http://code.google.com/p/modwsgi/wiki/IntegrationWithTrac Also look at other documentation on www.modwsgi.org site, including: http://code.google.com/p/modwsgi/wiki/ConfigurationGuidelines plus documentation on installation and application issues, which explain issues like the shared library not being used. Using daemon mode of mod_wsgi you can separate out your Django applications into distinct daemon processes for each site and therefore only incur memory use of site once for each site instead of once per Apache child process. If you have problems with memory leaks you can easily set maximum requests before daemon process restarted. You can also run each Django site as a distinct user if need be. If certain sites see more traffic to justify additional processes, then you can easily designate just for that site that it gets more than default single daemon process. In summary, with mod_wsgi it is much easier to control memory usage that mod_python. Graham --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---