On mod_wsgi daemon process' restarting
I have a wsgi application running as a mod_wsgi daemon process (in daemon mode). My setup is such that each daemon restarts after 1000 requests, as shown in the mod_wsgi configuration guidelines:
http://code.google.com/p/modwsgi/wiki/ConfigurationGuidelines
WSGIDaemonProcess www.site.com threads=1 processes=4 maximum-requests=1000
so that the lifetime on one daemon process is 1000 requests.
My question is: when is the daemon process restarted? Is it right after the maximum-requests limit finishes the开发者_StackOverflow previous one on is it on the next request?
EDITED: fixed typo in threads.
The use of 'maximum-requests' in production settings is not recommended unless your application is so broken that it leaks memory badly and you can't/don't want to fix it.
That said, the flag triggered by maximum requests is currently set at the start of the request which caused the count to reach that value. This is an implementation detail however and could change. In mod_wsgi 4.0 for example it will not be so clear cut as that version introduces a concept of graceful restart timeout in certain circumstances which means more requests may be handled before process actually restarts. Why is it important for you to know?
Also, why are you setting 'threads=0'? What do you think the result is going to be for that? It may not be what you think.
精彩评论