Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tuning mod_wsgi in daemon mode

Tags:

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?

like image 257
vonPetrushev Avatar asked Nov 12 '10 13:11

vonPetrushev


People also ask

What is WSGI daemon?

The WSGIDaemonProcess directive can be used to specify that distinct daemon processes should be created to which the running of WSGI applications can be delegated.

What is WSGIProcessGroup?

The WSGIProcessGroup directive can be used to specify which process group a WSGI application or set of WSGI applications will be executed in. All WSGI applications within the same process group will execute within the context of the same group of daemon processes.

What is Wsgiscriptalias?

Description: Maps a URL to a filesystem location and designates the target as a WSGI script.


2 Answers

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.

like image 196
mjhm Avatar answered Sep 22 '22 23:09

mjhm


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.

like image 21
GWW Avatar answered Sep 21 '22 23:09

GWW