3
At this point, we need to modify the parameter configuration under the corresponding <IfModule> node according to the MPM module used by the current Apache server. First, let's take a look at the default configuration under the Mpm_winnt module:
#由于mpm_winnt模块只会创建1个子进程, the parameter setting for a single subprocess here is equivalent to the entire Apache parameter setting. <ifmodule mpm_winnt_module> threadsperchild #推荐设置: Small website =1000 medium Web site =1000~2000 Large web site =2000~3500maxrequestsperchi LD 0 #推荐设置: Small =10000 Medium or large =20000~100000</ifmodule>
The corresponding configuration parameters function as follows:
Threadsperchild
The maximum number of concurrent threads per child process.
Maxrequestsperchild
The total number of requests that each child process is allowed to process. If the accumulated number of requests exceeds this value, the child process ends (and then determines whether to create a new child process as needed), which is set to 0 to not limit the total number of requests (the child process never ends).
This parameter is recommended to be set to a value other than zero, which provides the following two benefits:
You can run out of memory by preventing any memory leaks that may be present in the program from going on indefinitely.
Gives the process a limited lifespan, which helps reduce the number of active processes when the server load is reduced.
Note: In the above parameters that relate to the number of statistics requests, only the first request is counted for keepalive connections.
4
#mpm_perfork模块 <ifmodule mpm_prefork_module> startservers 5 #推荐设置: small = =20~50 large by default = 50~100minspareservers 5 #推荐设置: Consistent with startservers maxspareservers 10 #推荐设置: Small =20 30~80 Big =80~120 maxclients 150 #推荐设置: =500 large =500~1500 =1500~3000maxrequestsperchild in small &n Bsp 0 #推荐设置: Small =10000 Medium or large =10000~500000 (additionally, you need to set the Serverlimit parameter, which is best consistent with the value of maxclients. ) </IfModule> #mpm_worker模块 <ifmodule mpm_worker_module> startservers &NBSP;2 # Recommended settings: small = default in =3~5 large =5~10maxclients 150 #推荐设置: Small =500 =500~1500 Large =1500~ 3000MinSpareThreads 25 #推荐设置: small = default =50~100 large =100~200maxsparethreads 75 #推荐设置: small = Default in =80~160 big =200~400 threadsperchild 25 #推荐设置: small = default =50~100 large =100~200maxrequestsperchild 0 #推 Recommended settings: Small =10000 Medium or large =10000~50000 (in addition, if Maxclients/threadsperchild is greater than 16, you also need to set the Serverlimit parameter, Serverlimit mustmust be greater than or equal to the value of Maxclients/threadsperchild. ) </IfModule>
The corresponding configuration parameters function as follows:
Startservers
Number of child processes created when Apache was started.
Minspareservers
The number of the least-kid processes in the idle state.
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. This parameter needs to be adjusted only on very busy machines. This value shouldn't be too large.
Maxspareservers
The maximum number of child processes in an idle state.
This parameter needs to be adjusted only on very busy machines. This value shouldn't be too large. If you set the value of this directive to be smaller than Minspareservers, Apache will automatically modify it to minspareservers+1.
MaxClients
The maximum number of requests allowed to connect at the same time.
Any request exceeding the maxclients limit will enter the wait queue until the maximum value of the listenbacklog instruction limit is reached.
For non-threaded MPM (that is, mpm_prefork), maxclients represents the maximum number of child processes that can be used to process client requests, with the default value of 256. To increase this value, you must increase the serverlimit at the same time.
For a threaded or hybrid MPM (that is, Mpm_beos or Mpm_worker), maxclients represents the maximum number of threads that can be used to handle client requests. The default value for thread-type Mpm_beos is 50. The default value for a mixed type MPM is the result of serverlimit multiplied by (threadsperchild). So to increase maxclients to more than 16 processes to provide, you must increase the value of serverlimit at the same time.
Minsparethreads
The minimum number of threads in an idle state.
Different MPM handles this instruction differently:
The default value for Mpm_worker is 75. This MPM will monitor the number of idle threads based on the entire server. If the total number of idle threads in the server is too small, the child process will produce a new idle thread. The default value for Mpm_netware is 10. Since this MPM only runs a single sub-process, this MPM will of course monitor the number of idle threads based on the entire server. Mpm_beos and Mpmt_os2 work the same way as Mpm_netware, and the default value for Mpm_beos is 1;mpmt_os2, which is the default value of 5.
Maxsparethreads
The maximum number of threads in an idle state.
Different MPM handles this instruction differently:
The default value for Mpm_worker is 250. This MPM will monitor the number of idle threads based on the entire server. If the total number of idle threads in the server is too many, the child process kills the extra idle threads. The default value for Mpm_netware is 100. Since this MPM only runs a single sub-process, this MPM will of course monitor the number of idle threads based on the entire server. Mpm_beos and Mpmt_os2 work the same way as Mpm_netware, and the default value for Mpm_beos is 50;mpmt_os2, which is the default value of 10.
END