The following is the default configuration section of the worker:
StartServers 2
MaxClients 150 //Sets the total number of threads in all child processes. If the total number of threads in the existing child processes cannot satisfy the load, the controlling process will spawn a new child process.
MinSpareThreads 25 //The minimum number of idle threads is set
MaxSpareThreads 75 //The maximum number of idle threads is set. The maximum default values of MinSpareThreads and MaxSpareThreads are 75 and 250 respectively. In other words, do not define more than this here .
ThreadsPerChild 25
MaxRequestsPerChild 0 //It is the directive most closely related to performance in worker MPM. The maximum default value of ThreadsPerChild is 64. If the load is large, 64 is not enough. At this time, the ThreadLimit instruction must be used explicitly. Its maximum default value is 20,000. The above two values are located in the following two lines in the source tree server/mpm/worker/worker.c:
#define DEFAULT_THREAD_LIMIT 64
#define MAX_THREAD_LIMIT 20000
These two lines correspond to the limits of ThreadsPerChild and ThreadLimit. It is best to change 64 to the desired value before configure. Be careful not to set these two values too high to exceed the system's processing capabilities, which will make the system unstable because Apache does not start.
The total number of requests that can be processed simultaneously in Worker mode is determined by the total number of child processes multiplied by the ThreadsPerChild value, which should be greater than or equal to MaxClients. If the load is very large and the number of existing child processes cannot be satisfied, the control process will spawn new child processes. The default maximum total number of child processes is 16. When increasing the number, ServerLimit needs to be explicitly declared (the maximum value is 20000). These two values are located in the following two lines in the source tree server/mpm/worker/worker.c:
#define DEFAULT_SERVER_LIMIT 16
#define MAX_SERVER_LIMIT 20000
It should be noted that if ServerLimit is explicitly declared, then it is multiplied by The value of ThreadsPerChild must be greater than or equal to MaxClients, and MaxClients must be an integer multiple of ThreadsPerChild, otherwise Apache will automatically adjust to a corresponding value (which may be an unexpected value).
The above is the content of Apache performance optimization (5). For more related content, please pay attention to the PHP Chinese website (www.php.cn)!