Apache processes
Sources
http://forums.debian.net/viewtopic.php?f=16&t=54688
https://fuscata.com/kb/set-maxclients-apache-prefork
Recognize that Ubuntu 14.04 uses Apache 2 with PHP running through an mpm_prefork module, of which an editable file is in /etc/apache2/mods-enabled/mpm_prefork.conf. Also, recognize that starting in Apache 2.4, MaxClients is now renamed as MaxRequestWorkers, and so any documentation regarding MaxClients needs to be switched to MaxRequestWorkers.
It looks like 14.04 already sets this to 150 so issue evaporated.
1) install ps_mem.py to check memory usage
open a terminal and use the following commands
- CODE: SELECT ALL
wget http://www.pixelbeat.org/scripts/ps_mem.py
su
mv ps_mem.py /usr/local/sbin/
chmod 755 /usr/local/sbin/ps_mem.py
after you do that... as a user you can use the command ps_mem.py to check memory usage
result :
Private + Shared = RAM used Program4.0 KiB + 25.0 KiB = 29.0 KiB xinetd
4.0 KiB + 38.5 KiB = 42.5 KiB upstart-socket-bridge
..
88.0 KiB + 813.0 KiB = 901.0 KiB php5-fpm (5)
..
12.9 MiB + 13.5 MiB = 26.5 MiB /usr/sbin/apach (8)
..
160.1 MiB + 155.0 KiB = 160.3 MiB mysqld
248.8 MiB + 9.7 MiB = 258.5 MiB php-cgi (10)
347.1 MiB + 232.0 KiB = 347.3 MiB clamd
---------------------------------
893.6 MiB
Every 1.0s: echo -n 'Apache Processes: ' && ps -C php-cgi --no-headers | wc -l && free -m Sat Oct 22 11:18:27 2016
Apache Processes: 10
total used free shared buffers cached
Mem: 4096 3166 929 0 0 2113
-/+ buffers/cache: 1053 3042
Swap: 2048 155 1892
2) How To Change the Value MaxClients
The MaxClients value is located in the main Apache configuration file, typically /etc/apache2/apache2.conf (or /etc/httpd/httpd.conf.)
The relevant section looks like this:
# prefork MPM
# StartServers: number of server processes to start
# MinSpareServers: minimum number of server processes which are kept spare
# MaxSpareServers: maximum number of server processes which are kept spare
# MaxClients: maximum number of server processes allowed to start
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule mpm_prefork_module>
StartServers 5
MinSpareServers 5
MaxSpareServers 10
MaxClients 150
MaxRequestsPerChild 0
</IfModule>
After changing the value, save the file and restart Apache with apache2ctl graceful-stop && apache2ctl start
mut7 : /etc/apache2/apache2.conf
Calcul above. Setting to 50 in 3 places :
<IfModule mpm_prefork_module>
StartServers 1
MinSpareServers 1
MaxSpareServers 5
MaxClients 50
MaxRequestsPerChild 0
</IfModule>
<IfModule mpm_worker_module>
StartServers 1
MinSpareThreads 1
MaxSpareThreads 4
ThreadLimit 64
ThreadsPerChild 25
MaxClients 50
MaxRequestsPerChild 0
</IfModule>
<IfModule mpm_event_module>
StartServers 1
MinSpareThreads 1
MaxSpareThreads 4
ThreadLimit 64
ThreadsPerChild 25
MaxClients 50
MaxRequestsPerChild 0
</IfModule>
service apache2 restart