Home  >  Q&A  >  body text

Best practices for Apache memory and processes under high load

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

为情所困为情所困2702 days ago719

reply all(1)I'll reply

  • PHPz

    PHPz2017-05-16 17:05:02

    This is an article. . . Delete delete delete

    reply
    0
  • Cancelreply