Apache prefork / mod_wsgi spawns a number of processes of seemingly past configurations

in a production environment where nginx goes back to apache mpm-prefork / mod_wsgi, and I see 90 apache child processes when I expect 40 to be max, as described below. configuration / setup is nothing interesting:

  • nginx is reverse proxying on apache via proxy_pass and serving static media
  • apache only serves dynamic requests

corresponding nginx configuration:

 worker_processes 15; events { worker_connections 1024; } keepalive_timeout 10; 

corresponding apache configuration:

 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?

+4
source share
3 answers

The processes of the mod_wsgi daemon will be child processes of the Apache server, although they do not match. This is because the mod_wsgi daemon processes are fork of the parent Apache process, not fork / exec. In other words, the name of the executable does not change.

To be able to distinguish daemon mod_wsgi processes from normal Apache server child processes, set the 'display-name' option to WSGIDaemonProcess. This option allows you to rename the process as visible in the output from the ps program and some variants of programs such as top. See the documentation for the WSGIDaemonProcess directive at mod_wsgi.

http://code.google.com/p/modwsgi/wiki/ConfigurationDirectives#WSGIDaemonProcess

+10
source

It is possible to have more apache processes than WSGI instances.

Change apache MaxClients to 40 if you want to restrict apache processes.

0
source

You are using mod_wsgi in daemon mode, so the mod_wsgi processes and the Apache handler process are independent.

According to your configuration, immediately after starting apache you have:

  • The processes
  • 40 (processes =) mod_wsgi are launched at the same time.
  • 20 (StartServers) Apache handler processes that can be automatically reduced to 10 (MaxSpareServers) if there is no incoming activity.

Then, upon loading, Apache handler processes can grow to 200 (MaxClients). But mod_wsgi number of processes will be the same - 40.

My advice: use working mpm, than Apache only handles dynamic content. This can help reduce memory consumption and increase scalability.

0
source

All Articles