I have a small CGI application served via Apache2 and I would like to reduce the number of child processes that Apache2 maintains.
Here's the configuration (very basic) that I have for mpm_prefork.conf
:
$ cat /etc/apache2/mods-enabled/mpm_prefork.conf
<IfModule mpm_prefork_module>
StartServers 1
</IfModule>
Here's what I found regarding StartServers
:
The
StartServers
directive sets the number of child server processes created on startup.
Here's the number of processes that Apache is maintaining:
$ /etc/init.d/apache2 status
apache2.service - LSB: Apache2 web server
Loaded: loaded (/etc/init.d/apache2)
Drop-In: /lib/systemd/system/apache2.service.d
└─forking.conf
Active: active (running) since mar 2018-03-06 10:16:36 CST; 16min ago
Process: 9905 ExecStop=/etc/init.d/apache2 stop (code=exited, status=0/SUCCESS)
Process: 10117 ExecReload=/etc/init.d/apache2 reload (code=exited, status=0/SUCCESS)
Process: 9928 ExecStart=/etc/init.d/apache2 start (code=exited, status=0/SUCCESS)
CGroup: /system.slice/apache2.service
├─ 9942 /usr/sbin/apache2 -k start
├─10150 /usr/sbin/apache2 -k start
├─10151 /usr/sbin/apache2 -k start
└─10152 /usr/sbin/apache2 -k start
mar 06 10:16:36 server001 apache2[9928]: Starting web server: apache2.
mar 06 10:16:36 server001 systemd[1]: Started LSB: Apache2 web server.
mar 06 10:26:12 server001 systemd[1]: Reloading LSB: Apache2 web server.
mar 06 10:26:12 server001 apache2[10050]: Reloading web server: apache2.
mar 06 10:26:12 server001 systemd[1]: Reloaded LSB: Apache2 web server.
mar 06 10:33:29 server001 systemd[1]: Reloading LSB: Apache2 web server.
mar 06 10:33:29 server001 apache2[10117]: Reloading web server: apache2.
mar 06 10:33:29 server001 systemd[1]: Reloaded LSB: Apache2 web server.
Every child process, is consuming something above 50Mb, and sincerely, for the type of application that I have, just one child would be enough.
$ ps -ylC apache2
S UID PID PPID C PRI NI RSS SZ WCHAN TTY TIME CMD
S 0 9942 1 0 80 0 25976 56792 - ? 00:00:00 apache2
S 33 10150 9942 0 80 0 8416 36091 - ? 00:00:00 apache2
S 33 10151 9942 0 80 0 8864 36097 - ? 00:00:00 apache2
S 33 10152 9942 0 80 0 8716 56798 - ? 00:00:00 apache2
Here are my questions:
- Why I still have a main process + 3 child, instead of a main process + 1 child ?
- What configuration should I use, in order to reduce the number of child processes ?
I'm a little bit new with Apache2. So please, be patient with my doubt.