I have a django application in which i am using python Thread module to do multi threading, it works fine while using django development server through manage.py. But when i deploy on apache - mod_wsgi, its not working .join is failing and threading not working. Can anyone help for exact apache configuration ?
i tried keeping some multithread and multiprocess configuration like follows. But still not working. My configuration - Listen 8000
Alias /static/ /usr/td/static/
<Directory /usr/td/static/>
Require all granted
</Directory>
<Directory /usr/td>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIDaemonProcess td display-name=myproject processes=10 threads=255 python-path=/usr/td/:/usr/lib/python2.7/site-packages
WSGIProcessGroup td
WSGIScriptAlias / /usr/td/td/wsgi.py
There is nothing in mod_wsgi that stops you from using threading, although running background tasks in a web application process is often a bad idea. Depending on what you are doing, you should use a separate task queuing system such as Celery.
One thing that stands out as indicating you are going off in the wrong direction is that you have set threads=255. This is the number of concurrent threads for accepting requests. It is nearly always a very bad idea to set such a high number.
Right now you have set up a request thread pool size across all mod_wsgi daemon processes of 2550 threads, which is way more than Apache itself can even proxy. So it is just a waste of memory as would never be used.
Even 25 threads would be regarded as being high and you definitely don't want to use a large number of threads if the process is doing high CPU tasks as the threading model and GIL of Python don't make it practical.
Why are you using such a high number of threads? That number is nothing to do with any background threads you may create yourself to do stuff, it is only indicating number of web request handler threads.
Suggest you actually show a bit about the actual threading code you are trying to run. The Apache/mod_wsgi configuration has really got nothing to do with it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With