Hi!
I have a rather strange set up, for running a django intranet site.
It is currently running on a Windows XP box with Apache 2.2 with
mod_python and MySQL.
The site is rather prone with database queries. The most complex page on
the site reports to be executing around 350 sql queries.
The site is done with everything in one single django application.
The views of the site are spread across two files taking close under
2000 lines of code.
I do not cache in any way.
This is so, because the site is more of a management application than a
normal public site. There are many parts of each page that are
calculations that have to be exact and have to be calculated on each
request.
In this scenario, I've ended up having a site capable of getting the CPU
of the box down to it's knees on EACH request.
Each single request will get the CPU to 100% and the page won't
completely render before 5-7 seconds have passed. When more persons
interact with the server, it isn't capable of responding appropriately
anymore.
The curious thing is that it's not MySQL that is responsible of all that
CPU usage, but the Apache process.
The same thing happens if I load the site with the development server
via manage.py runserver.
It's also not my views which are causing the trouble.
Setting up a timer at the start and end of the most complicated view
shows that the app gets through that part in approximately 0.2-0.3 seconds.
It seems clearly that the rendering of the templates is responsible for
eating up all of the CPU's resources.
One thing I have done since the start of the project, and which might
be part of the problem, has been to end all the views like this:
return render_to_response('myapp/mytemplate.html', locals(),
context_instance=RequestContext(request))
I'm passing the locals() variable dict to the template and also the request.
This post is to ask for some guidance or ideas on how to tackle the problem.
I hope there is a simple and obvious reason for this performance
bottleneck...
I have started to cache, (currently via the in-memory cache option, to
keep it simple). The approach is to use the "cache" template tag to
cache portions of my templates which don't need to be refreshed on each
request and which do require calls to the database.
Any suggestions will be appreciated.
Regards, Stefan Tunsch
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---