in a production environment running nginx reversing back to apache mpm-prefork/mod_wsgi, im seeing 90 apache child processes, when i would expect that 40 would be the maximum, as configured below. the configuration/setup is nothing exciting:
- nginx is reverse proxying to apache via
proxy_pass
, and serving static media - apache only serves dynamic requests
relevant nginx config:
worker_processes 15;
events {
worker_connections 1024;
}
keepalive_timeout 10;
relevant apache config:
KeepAlive Off
MaxKeepAliveRequests 100
KeepAliveTimeout 15
<IfModule mpm_prefork_module>
StartServers 20
MinSpareServers 7
MaxSpareServers 10
MaxClients 200
MaxRequestsPerChild 0
</IfModule>
mod_wsgi config, where webapp
is the name of the process:
WSGIDaemonProcess webapp user=www group=users threads=1 processes=40
am i missing something?
You are using
mod_wsgi
in daemon mode, somod_wsgi
processes and Apache handler process are independent.By your configuration right after the apache starts you have:
mod_wsgi
processes are started the same time.Then on load, Apache handler processes can grow up to 200(MaxClients). But
mod_wsgi
processes count will be the same - 40.My advice is to use worker mpm than Apache processes only dynamic content. It can help to reduce memory consumption and better scalability.
The mod_wsgi daemon processes will appear to be Apache server child processes even though they aren't the same. This is because the mod_wsgi daemon processes are a fork of Apache parent process and not a fork/exec. In other words, they executable name doesn't change.
To be able to distinguish mod_wsgi daemon processes from normal Apache server child processes, supply the 'display-name' option to WSGIDaemonProcess. This option allows you to rename the process as viewable in output from 'ps' program and some variants of programs like 'top'. See documentation of WSGIDaemonProcess directive on mod_wsgi site.
http://code.google.com/p/modwsgi/wiki/ConfigurationDirectives#WSGIDaemonProcess
It's possible to have more apache processes than WSGI instances.
Change apache's MaxClients to 40 if you want to limit the apache processes.