Best practices for Apache memory and processes under high load
为情所困
为情所困 2017-05-16 17:03:02
0
1
718

Check whether Apache is running in prefork working mode

apachectl -V | grep MPM
httpd -V | grep MPM

Server MPM:     Prefork
 -D APACHE_MPM_DIR="server/mpm/prefork"

View the memory currently occupied by each process

top -bn 1 | grep httpd

 56961 apache    20   0  406m  49m  40m S  1.9  0.1   0:21.92 httpd
 56963 apache    20   0  406m  53m  44m S  1.9  0.1   0:20.45 httpd
 56967 apache    20   0  402m  52m  42m S  1.9  0.1   0:20.28 httpd
 56971 apache    20   0  404m  54m  44m S  1.9  0.1   0:21.18 httpd
 56974 apache    20   0  415m  55m  42m S  1.9  0.1   0:20.07 httpd

RES column is the amount of memory used by the Apache process, the sixth column from the left.

Calculate the number of processes

Maximum number of processes = total amount of memory that Apache can consume/amount of memory consumed by each process

Set related parameters

<IfModule prefork.c>
StartServers                30%MaxClients
MinSpareServers               5%
MaxSpareServers                 10%
ServerLimit                 256
MaxClients                  200 = 10G/50M
MaxRequestsPerChild 10000
</IfModule>

restart

  • Apache will actually control the process within this framework. For example, when the load is not high, the process will be automatically reduced.
  • The key to apache planning is the amount of memory at maximum load, which is different from nginx
  • Calculate the MaxClients value
  • through the maximum amount of memory
  • All other values ​​are calculated based on MaxClients
为情所困
为情所困

reply all(1)
PHPzhong

This is an article. . . Delete delete delete

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!