> Hi, > > We are testing a uwsgi configuration where we host several hundreds > django applications with uwsgi virtualhosting mode (through apache for > now). Each apache virtualhost is associated with its own application. We > use virtualhosting for applications that are not accessed often and > emperor/dedicated process for applications that receive more traffic.
ok, this is a good usage of both technics (virtualhosting and multiple instances) > > I was wondering what strategy uwsgi uses to dispatch the requests to the > process pool? For example, does it try to reuse the same > subinterpreter/process unless the process is servicing another request > for another app? Does it allocate subinterpreters to processes using > round-robin or ...? the rule in virtualhosting mode is 1 interpreter -> 1 app. Each app will live in its interpreter in the process, and when uWSGI receive the request it choose the interpreter to set. So if you set 10 processes for this instance and you host 5 virtualhosts, you will ends with 50 interpreters (5 per process) > > I mainly ask this question because I noticed that requests for the same > host/app do not often go to the same process and uwsgi ends up creating > many wsgi applications when it did not seem necessary. by default uWSGI allocate all the resources you have configured, if you want a less-aggressive setup you can look at --cheap and --cheaper modes (the second one is probably more useful for your needs as it allows you to spawn processes only when needed) Cheaper mode is a feature of 1.0 (it is available in the rc1 too). Its usage is very simple: --processes 8 --cheaper 2 means: starts with 2 processes and if needed spawn the others, one at time, and eventually stop them after inactivity leaving at least 2 processes always running. --idle mode is another useful option (available in both 0.9.8 and 0.9.9). You specify the number of seconds after wich an instance is put in cheap (or cheaper) mode. Cheap mode is more simple, it starts the uWSGI master process and then spawn the workers only at the first request. After inactivity all of the workers are stopped/destroyed. > One last question, does it make sense and is it supported to use threads > with virtualhosting (e.g., uwsgi --threads 10 --workers 60 --vhost)? it is supported, but take in account that you will end with 600 threads * number_of_interpreters. It could be a huge amount of memory. If you want you can decrease the thread stack usage with --thread-stacksize 512 that will reduce it to 512k (should be enough for pratically all of the apps out there) -- Roberto De Ioris http://unbit.it _______________________________________________ uWSGI mailing list [email protected] http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi
