Sloooooowwwww WSGI restart

Graham Dumpleton Graham.Dumpleton at gmail.com
Wed Jan 28 20:10:19 EST 2009


On Jan 29, 8:35 am, Ron Garret <rNOSPA... at flownet.com> wrote:
> I'm running a WSGI app under apache/mod_wsgiand I've noticed that
> whenever I restart the server after making a code change it takes a very
> long time (like a minute) before the script is active again.  In other
> words, I do an apachectl restart, reload the page in my browser, and one
> minute later it finally comes up.  During this time CPU usage is
> essentially zero.  Loading all the code manually into a python
> interpreter is virtually instantaneous, and all subsequence interactions
> with the app are very fast.
>
> Does anyone have any ideas what might be going on or how to debug this?

The better place to discuss this is the mod_wsgi list.

  http://groups.google.com/group/modwsgi?hl=en

As to the problem, you need to distinguish between whether it is
Apache that is taking a long time to restart and ready to handle
requests, or whether the delay is on the first subsequent request made
against your WSGI application.

When Apache restarts, it doesn't by default load your WSGI
application, it only does that the first time a request comes in
directed at it. Thus, if after you restart Apache you do a request of
a static file, do you get a response straight away? If it doesn't
respond straight away, then it is an issue with Apache restart and not
mod_wsgi as your WSGI application wouldn't be involved.

If the static file request is fine and only first request to WSGI
application is slow, then likely that problem is to do with the
startup cost of loading your WSGI application and initialising it upon
first request. As you don't say what Python web framework/application
you are using, hard to say what the issue may be there.

If it is an Apache issue and not mod_wsgi, as pointed out already,
could be that you have Apache setup to do reverse DNS lookups on
client IP address and that isn't working properly. This often happens
for Windows people.

So, narrow down where problem is occurring.

Graham



More information about the Python-list mailing list