Tuning mod_wsgi in daemon mode

11,387

Solution 1

You might get more information on ServerFault as well. For example: https://serverfault.com/questions/145617/apache-2-2-mpm-worker-more-threads-or-more-processes

This is another good resource for the topic: http://code.google.com/p/modwsgi/wiki/ProcessesAndThreading#The_mod_wsgi_Daemon_Processes which briefly describes the options -- including setting threads = 1.

I haven't done this yet but it sounds like it doesn't much matter. Supporting multiple threads as well as multiple processors are both well supported. But for my experience level (and probably yours) its worthwhile to eliminate threading as an extra source of concern -- even if it is theoretically rock solid.

Solution 2

Your best bet is to probably try different bench marks. You can use the apache benchmark command to get a rough estimate at how your configuration is doing. A lot of the tweaking is going to depend on how CPU / IO bound your web app is. The performance is also going to depend on the specs of the server you are hosting on etc.

Share:
11,387
vonPetrushev
Author by

vonPetrushev

Data Scientist @ Trivago Apache Spark in production - Bayesian in the heart https://petrushev.github.io/

Updated on June 20, 2022

Comments

  • vonPetrushev
    vonPetrushev almost 2 years

    I'm running wsgi application on apache mod_wsgi in daemon mode. I have these lines in the configuration

    WSGIDaemonProcess app processes=2 threads=3 display-name=%{GROUP} 
    WSGIProcessGroup app
    

    How do I find the optimal combination/tuning of processes and threads?

    EDIT: This link [given in answer bellow] was quite usefull: https://serverfault.com/questions/145617/apache-2-2-mpm-worker-more-threads-or-more-processes/146382#146382

    Now, my question is this: If my server gives quite good performance for my needs, should I reduce the number of threads to increase stability / reliability? Can I even set it to 1?

  • vonPetrushev
    vonPetrushev over 13 years
    I only saw your update now. I think I will go with single thread. Thank you.