I have an Apache2 + mod_python setup which has begun responding impossibly slow since some days – two seconds of processor time for any request of my app.
Some interesting points:
- Debugbar says it’s ~15ms of query time. DB is not the main suspect
- Logging with datetime.now() shows 0.1s is spent inside the view, and 40ms more are spent inside a requestcontext
- I could not find an easy way to time template rendering.
Any idea of where can I look?
Suppose it had an infinite loop. How would you find it?
I imagine you would just pause it in the debugger and look at the code at the various levels of the stack, because you know the loop is somewhere on the stack. Right?
Suppose the loop isn’t infinite, merely taking a long time. Is that much different?
No matter what the problem is, if it is costing you some percent of time, like 90%, or 50%, or 20%, that’s the probability you will catch it in the act when you pause it. So if you pause it several times, you’re going to see it. The worse it is, the fewer times you have to pause it and look. It will be obvious.
So forget about timing. Just find out what it’s doing.
In response to question, here is some mod_python doc: