[mod_python] Re: Django-mod_python taking time loading libraries

Graham Dumpleton graham.dumpleton at gmail.com
Wed Dec 23 05:55:59 EST 2009


What else is your Apache being used for? If it is being use for other
stuff it may not be possible to tune Apache embedded in a way that is
best for Python web application as that will be too detriment of other
stuff you are hosting.

So, are you hosting static media on same Apache or using a separate
web server such as nginx for static media? Are you running PHP using
mod_php on same Apache? Are you running anything else using any
fastcgi/scgi/ajp hosting mechanisms?

In short, unless that Apache is dedicated to just the Python web
application, the trouble of trying to tune Apache for it is no worth
the trouble and just better off using daemon mode thus allowing you to
separately control things.

BTW, depends a bit on what your site is doing, but using nginx proxy
front end can be very advantageous as isolates Apache from slow
clients allowing Apache processes/threads to be better utilised.

Graham

2009/12/23 bharath venkatesh <bharathv6.project at gmail.com>:
> Hi Graham,
>
>      Thanks for the link it was very informative
> - Technically running embedded mode with prefork MPM should offer the best
> performance, especially for machines with many cpus/cores.
> - just because mod_wsgi embedded mode and prefork MPM may be the fastest
> solution out there for Apache
> As above lines (from link ) suggests ,can we use mod_wsgi embedded mode and
> prefork MPM (as meantioned that it is best ) ?and tune apache not to load
> libraries and intialise every thime  (as our apache is already running as
> prefork MPM and also our machines are multi core (8 cores) and has 16 AG
> Ram)  or we have to use mod_wsgi in daemon mode to pervent huge loading and
> intialising time ? but  as daemon mode is used with worker MPM we have to
> recompile apache
> Thanks,
> Bharath
>
> On Wed, Dec 23, 2009 at 3:19 AM, Graham Dumpleton
> <graham.dumpleton at gmail.com> wrote:
>>
>> 2009/12/23 bharath venkatesh <bharathv6.project at gmail.com>:
>> > will mod wsgi in Daemon mode  solve this issue  as loading libraries and
>> > initialising is done only once ?
>>
>> Maybe.
>>
>> As documented in:
>>
>>
>>  http://blog.dscpl.com.au/2009/03/load-spikes-and-excessive-memory-usage.html
>>
>> the OP is having problems because of how embedded mode Python
>> applications work in Apache. This may be  exacerbated by using prefork
>> MPM with Apache. Same issues come up with mod_wsgi embedded mode as
>> with mod_python if you do not configure your Apache correctly for fat
>> Python web applications. If you are limited in being able to do that
>> because Apache is heavily used for static file serving or mod_php, you
>> really should use mod_wsgi daemon mode instead as described in that
>> post.
>>
>> Why daemon mode will help is fixed number of persistent processes and
>> more specifically defaulting to one process, so you only incur startup
>> cost once and not for many processes, or in case of embedded mode also
>> not when the processes get recycled as is default for Apache.
>>
>> Graham
>>
>> > On Tue, Dec 22, 2009 at 5:13 PM, bharath venkatesh
>> > <bharathv6.project at gmail.com> wrote:
>> >>
>> >> Hi,
>> >>
>> >>     Django with mod python  is taking time loading libraries . I am
>> >> using
>> >> python  open source libraries like montylingua , simplejson and django
>> >> is
>> >> taking
>> >> time loading these libraries .
>> >>
>> >> When django is run using python manage.py runserver first request takes
>> >> time but rest of the requests doesn't take time ( quite fast ) ,which
>> >> is
>> >> acceptable but when django is used along with apache and mod_python it
>> >> takes
>> >> time as much time as django takes for first request  when run using
>> >> python
>> >> manage.py runserver for almost every request.
>> >>
>> >> How to avoid this as our performance is greatly hindered by this
>> >> behaviour
>> >>
>> >> is it possible to cache these external open source libraries  ?
>> >>
>> >> Thanks in Advance,
>> >> Bharath
>> >
>> > _______________________________________________
>> > 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