In general, IIS is used in WinNT systems, while Apache has many applications in Linux, but many people still use Apache rather than IIS in WinNT systems, it may be based on familiarity with Windows systems. Today, we will discuss how to optimize Apache performance in Windows.
Mpm_winnt.c is a dedicated MPM (multi-channel processing module) optimized for Windows NT. It uses a separate parent process to generate a separate sub-process, in this sub-process, multiple threads are generated in turn to process requests. That is to say, mpm_winnt can only start two processes: parent and child. It cannot start multiple processes at the same time as in Linux.
Mpm_winnt optimizes Apache through the ThreadsPerChild and MaxRequestsPerChild parameters. The following describes in detail.
ThreadsPerChild
This parameter is used to set the number of threads for each process. When a sub-process is started, these threads are created and no new threads are created. on the one hand, because mpm_winnt cannot start multiple processes, this value must be large enough to handle possible request peaks. On the other hand, this parameter is subject to the server response speed, if the number is too large, it slows down. Therefore, a reasonable value must be balanced comprehensively.
The default value on mpm_winnt is 64, and the maximum value is 1920. We recommend that you set the value between and. If the server performance is high, the value is larger. Otherwise, the value is smaller.
MaxRequestsPerChild
This parameter table shows the maximum number of requests that each sub-process can process, that is, the number of sub-processes in the same time. If it is set to 0, it indicates no limit. The default value on mpm_winnt is 0.
It is not recommended to set the value to 0 in the official reference manual. It is mainly based on two considerations: (1) it can prevent (accidental) unlimited memory leakage and thus exhaust the memory; (2) a limited life cycle is provided for processes, which helps reduce the number of active processes when server load is reduced.
Therefore, the value of this parameter depends more on the server memory. If the memory is large, you can set it to 0 or a large number. Otherwise, you can set a small value. It should be noted that if this value is set too small, Apache will frequently restart and the following text will be displayed in the log file:
The code is as follows: |
Copy code |
Process exiting because it reached MaxRequestsPerChild. Signaling the parent |
This reduces the overall performance of Apache.
In addition, you can check the server-status (status report) provided by Apache to verify whether the currently set value is reasonable. In the httpd. conf file, make the following settings to open it:
# First load the mod_status module
LoadModule status_module modules/mod_status.so
# Set the access address
The code is as follows: |
Copy code |
<Location/server-status> SetHandler server-status Order deny, allow Deny from all # If you restrict access from an IP address, set it to Allow from 192.168.1.1. Allow from all </Location>
|
In general, because in Windows NT, Apache can only start two processes: parent and child. Therefore, it can only be optimized by increasing the number of threads of a single process and the maximum number of requests that a single process can process. Other optimized parameters are the same as those in Linux. The following two parameters are recommended:
The code is as follows: |
Copy code |
<IfModule mpm_winnt.c> ThreadsPerChild 250 MaxRequestsPerChild 5000 </IfModule> |