Apache eats empty memory, frequent downtime
In the deployment of a set of intranet test environment, frequent downtime, after the boot constantly eat memory, restart Apache after the memory consumption will continue to rise, until the swap runs out, until the crash, due to the intranet environment, the server concurrency and pressure are very small.
Check the Apache error log for a number of similar errors:
[Tue Feb 14 14:49:28 2012] [Warn] child process 7751 still do not exit, sending a SIGTERM
[Tue Feb 14 14:49:30 2012] [ERROR] Child process 7603 still does not exit, sending a SIGKILL
[Tue Feb 14 14:49:30 2012] [ERROR] Child process 7614 still does not exit, sending a SIGKILL
This is because PHP has some script that has a memory leak code snippet. The number of processing requests for the process in which Apache processes these snippets is set to infinity. This means that these processes will only be killed if the Apache restarts (Stop-start mode) or the server restarts, otherwise it will run until the last resource of the system (mainly memory) is exhausted.
Problem Analysis:
Maximum number of processes allowed to be configured by the server
Serverlimit 1500
Sets the number of child processes that are established when the server starts. Because the number of child processes dynamically depends on the weight of the load, it is generally not necessary to adjust this parameter.
Startservers 5
Minspareservers: Sets the minimum number of idle child processes. The so-called idle child process refers to a child process that is not processing the request. If the number of currently idle child processes is less than minspareservers, then Apache will produce a new subprocess at a maximum speed of one second.
Minspareservers 5
Sets the maximum number of idle child processes. If there are currently more than maxspareservers of idle child processes, the parent process kills the extra child processes.
Maxspareservers 10
Maximum number of Access requests (maximum number of threads) for client requests.
MaxClients 1500
Set the maximum number of requests that each child process is allowed to provide during its lifetime
Maxrequestsperchild 50
Problem Solving:
Set Maxrequestsperchild 50 or 30
Maxrequestsperchild can not be too large, nor set to 0, preferably set to a relatively small number, 100 may be enough to prevent the httpd process has an unexpected memory leak.