2008/12/23 meppum <mmep...@gmail.com>: > > Okay, lets see if I have this right... > > If i have 2 apache servers and each apache server can have 25 threads > that's 50 threads total. > > If mod_wsgi is running in daemon mode does that mean that each apache > thread will spawn a mod_wsgi daemon?
No. The mod_wsgi daemon process(es) are spawned by the Apache parent process. Only the number configured by the 'processes' option to WSGIDaemonProcess directive will be created. If the 'processes' option is not defined then only 1 process is created. Note, do not specify 'processes=1' however unless you know why you want to do this. If want only 1 process let it default to creating 1 instead. > And if each daemon has 15 threads > does that mean that there can be 50 (apache) x 15 (mod_wsgi) = 750 > connections? No. In the case of the WSGI application, the Apache child worker processes only act as a proxy, forwarding the requests across to the mod_wsgi daemon mode process(es) for handling. Thus, with 2 Apache child worker processes, maximum number of connections is 50 (where each has 25 threads). These Apache child worker processes accept connections for both static file requests and dynamic requests which are then proxied across to the mod_wsgi daemon mode process. With only a single mod_wsgi daemon mode process, the WSGI application itself will be able to handle 15 concurrent requests. If there are requests being handled by mod_wsgi daemon mode process, because the Apache child worker processes is proxying the requests and responses, a thread is still consumed for the life of the request in the Apache child worker processes. The 35 (50-15) additional threads in Apache child worker processes would still be available for handling static requests, keep alive connections and acting as a buffering mechanism for pending dynamic requests against WSGI application. The latter particularly useful for slow clients as apache child worker processes will not forward request onto mod_wsgi daemon process until full request information available. Note that just because mod_wsgi daemon mode process can only handle 15 concurrent requests doesn't mean that it can only handle that many requests per second. How many requests per second is going to be dictated by how slow your application is and what contention there is on shared resources. The latter have an impact on whether operations need to be serialised. Overall, just think of mod_wsgi daemon mode as being similar to using mod_proxy in front of a separate back end web server. In this case though mod_wsgi has created the daemon processes and is managing them on your behalf. Graham > On Dec 22, 1:37 am, "Graham Dumpleton" <graham.dumple...@gmail.com> > wrote: >> 2008/12/22 meppum <mmep...@gmail.com>: >> >> >> >> > What about apache mpm settings? Any examples on what they should be >> > for say the default WSGIDaemonProcess setting of 15 threads? Thanks. >> >> The defaults for standard Apache source distribution are: >> >> # worker MPM >> # StartServers: initial number of server processes to start >> # MaxClients: maximum number of simultaneous client connections >> # MinSpareThreads: minimum number of worker threads which are kept spare >> # MaxSpareThreads: maximum number of worker threads which are kept spare >> # ThreadsPerChild: constant number of worker threads in each server process >> # MaxRequestsPerChild: maximum number of requests a server process serves >> <IfModule mpm_worker_module> >> StartServers 2 >> MaxClients 150 >> MinSpareThreads 25 >> MaxSpareThreads 75 >> ThreadsPerChild 25 >> MaxRequestsPerChild 0 >> </IfModule> >> >> This is a reasonable starting point. >> >> This allows for a lot more concurrent connections, but if you are also >> serving static files and default of keepalive being on is still in >> use, the maximum of 150 clients is okay, especially since it will only >> create more than 2 Apache child worker processes if it really needs >> to. >> >> I would only bother starting to fiddle with the defaults when you have >> realistic estimates of the sort of load you would need to handle. >> >> Graham >> >> > On Nov 18, 7:44 pm, "Rob Hudson" <treborhud...@gmail.com> wrote: >> >> On Tue, Nov 18, 2008 at 2:51 PM, Graham Dumpleton >> >> >> <graham.dumple...@gmail.com> wrote: >> >> > Hmmm, even 10000 hits per day is not a large site. >> >> >> Yeah, that's why I said "larger" to keep it relative. But doing the >> >> math and averaging out hits evenly, that's 1 request every 11 seconds >> >> or so... definitely not large at all. >> >> >> > For that would just not bother setting processes or threads and just >> >> > let WSGIDaemonProcess default to single process with 15 threads. That >> >> > should be more than adequate. >> >> >> OK. After doing that on my slicehost account, it looks like it >> >> actually reduced memory compared to what I had previously, so that's a >> >> nice side effect when I'm always looking at how far away the 256M >> >> limit is. Previously I think I was using 2 processes and 1 thread... >> >> no idea where I got that idea from. I think I had it in my mind that >> >> Django shouldn't be run multithreaded, which might have been true at >> >> one point but is no longer true today. > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "modwsgi" group. To post to this group, send email to modwsgi@googlegroups.com To unsubscribe from this group, send email to modwsgi+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/modwsgi?hl=en -~----------~----~----~----~------~----~------~--~---