I'm running Apache 2.2. I have 10 apache
processes running, and it's taxing my limited resources.
I have searched for the config option that controls how many processes are spawned, but I could use some help. Is it MaxRequestWorkers
? Is it ThreadsPerChild
? Something else? (Neither appears to be set in my config files.)
Here's an example of one of my apache
processes:
F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD
5 S 33 26099 25513 0 80 0 - 56951 poll_s ? 1:42 /usr/sbin/apache2 -k start
Edit:
I'm sorry. I am running apache 2.2, not 2.4.
list of mods-enabled:
lrwxrwxrwx 1 root root 28 Sep 5 2014 alias.conf -> ../mods-available/alias.conf
lrwxrwxrwx 1 root root 28 Sep 5 2014 alias.load -> ../mods-available/alias.load
lrwxrwxrwx 1 root root 33 Sep 5 2014 auth_basic.load -> ../mods-available/auth_basic.load
lrwxrwxrwx 1 root root 33 Sep 5 2014 authn_file.load -> ../mods-available/authn_file.load
lrwxrwxrwx 1 root root 36 Sep 5 2014 authz_default.load -> ../mods-available/authz_default.load
lrwxrwxrwx 1 root root 38 Sep 5 2014 authz_groupfile.load -> ../mods-available/authz_groupfile.load
lrwxrwxrwx 1 root root 33 Sep 5 2014 authz_host.load -> ../mods-available/authz_host.load
lrwxrwxrwx 1 root root 33 Sep 5 2014 authz_user.load -> ../mods-available/authz_user.load
lrwxrwxrwx 1 root root 32 Sep 5 2014 autoindex.conf -> ../mods-available/autoindex.conf
lrwxrwxrwx 1 root root 32 Sep 5 2014 autoindex.load -> ../mods-available/autoindex.load
lrwxrwxrwx 1 root root 26 Sep 5 2014 cgi.load -> ../mods-available/cgi.load
lrwxrwxrwx 1 root root 30 Sep 5 2014 deflate.conf -> ../mods-available/deflate.conf
lrwxrwxrwx 1 root root 30 Sep 5 2014 deflate.load -> ../mods-available/deflate.load
lrwxrwxrwx 1 root root 26 Sep 5 2014 dir.conf -> ../mods-available/dir.conf
lrwxrwxrwx 1 root root 26 Sep 5 2014 dir.load -> ../mods-available/dir.load
lrwxrwxrwx 1 root root 26 Sep 5 2014 env.load -> ../mods-available/env.load
lrwxrwxrwx 1 root root 27 Sep 5 2014 mime.conf -> ../mods-available/mime.conf
lrwxrwxrwx 1 root root 27 Sep 5 2014 mime.load -> ../mods-available/mime.load
lrwxrwxrwx 1 root root 34 Sep 5 2014 negotiation.conf -> ../mods-available/negotiation.conf
lrwxrwxrwx 1 root root 34 Sep 5 2014 negotiation.load -> ../mods-available/negotiation.load
lrwxrwxrwx 1 root root 32 Sep 12 2014 passenger.conf -> ../mods-available/passenger.conf
lrwxrwxrwx 1 root root 32 Sep 12 2014 passenger.load -> ../mods-available/passenger.load
lrwxrwxrwx 1 root root 27 Sep 5 2014 php5.conf -> ../mods-available/php5.conf
lrwxrwxrwx 1 root root 27 Sep 5 2014 php5.load -> ../mods-available/php5.load
lrwxrwxrwx 1 root root 33 Sep 5 2014 reqtimeout.conf -> ../mods-available/reqtimeout.conf
lrwxrwxrwx 1 root root 33 Sep 5 2014 reqtimeout.load -> ../mods-available/reqtimeout.load
lrwxrwxrwx 1 root root 40 Sep 14 2014 rewrite.load -> /etc/apache2/mods-available/rewrite.load
lrwxrwxrwx 1 root root 31 Sep 5 2014 setenvif.conf -> ../mods-available/setenvif.conf
lrwxrwxrwx 1 root root 31 Sep 5 2014 setenvif.load -> ../mods-available/setenvif.load
lrwxrwxrwx 1 root root 36 Jun 7 2015 ssl.conf -> /etc/apache2/mods-available/ssl.conf
lrwxrwxrwx 1 root root 36 Jun 7 2015 ssl.load -> /etc/apache2/mods-available/ssl.load
lrwxrwxrwx 1 root root 29 Sep 5 2014 status.conf -> ../mods-available/status.conf
lrwxrwxrwx 1 root root 29 Sep 5 2014 status.load -> ../mods-available/status.load
It depends which mpm module (mpm_worker/mpm_prefork/mpm_event) your apache is using. If you are unsure, then post the output of
cat /etc/apache2/mods-enabled/mpm*.conf
which reveals the number of StartServers/MinSpareServers/MaxSpareServers, MaxRequestWorkers and maybe ThreadsPerChild and ThreadLimit. If the filenames should be different in your linux distro, then post an output of your enabled modulesls -l /etc/apache2/mods-enabled
.It should look like something like this and explains itself (Debian, Apache2.4):
See Reducing Apache Memory usage and Average Process Size Value
The documentation says (as described in the link above):
Example:
Running the cool script from the linked page above gives me:
Note: "Average Process Size" is the "RES" value when you run
top
.To determine
MaxClients
(akaMaxRequestWorkers
), I need to calculate:Check which mpm module (mpm_worker/mpm_prefork/mpm_event) your apache is using by running: httpd -V
With that information, access apache site (eg prefork or worker or event https://httpd.apache.org/docs/2.4/mod/prefork.html or worker.html or event.html) to review the configuration required. I'm using prefork with the following settings:
where