mod_wsgi and Django app periodically hang
I've got a large Django app. It has two Apache virtual hosts pointing to different setting开发者_Python百科s files, so part of the application is accessible via one URL, and part via another. The Django app uses virtualenv.
mod_wsgi is configured to run in daemon mode with the following in Apache's VirtualHost block:
# domain 1:
WSGIDaemonProcess fc processes=5 threads=5 display-name=%{GROUP} \
user=nobody group=nobody
WSGIScriptAlias / /var/www/python/mine/apache/my.wsgi \
process-group=fc application-group=%{GROUP}
# different apache.conf file for domain 2:
WSGIDaemonProcess fm processes=5 threads=5 display-name=%{GROUP} \
user=nobody group=nobody
WSGIScriptAlias / /var/www/python/mine/apache/other.wsgi \
process-group=fm application-group=%{GROUP}
Every now and again while using the sites, a request will hang. It never completes. I have to use the browser's 'refresh' button to reload the page, and then the request normally works.
Apache itself runs in prefork mode and MaxRequestsPerChild is set to 0 because I've read that could be a problem. This happens often enough for it to be a potential problem - every 100 requests perhaps, something like that.
Has anyone got any idea why this is happening?
Thanks
That should be 'application-group=%{GLOBAL}' for WSGIDaemonProcess options, not '%{GROUP}'. The '%{GLOBAL}' is special and means the main Python interpreter. Using the main interpreter often gets around problems with third party C extension modules for Python which don't work in sub interpreters, including experiencing deadlocks. The '%{GROUP}' value is only relevant to the 'display-name' option.
精彩评论