High performance Apache server configuration large Concurrent Tutorial MPM module configuration

Source: Internet
Author: User


Apache is a cross-platform Web server, because of its simple and efficient, stable security features, is widely used in computer technology in all areas. Now, with its huge number of users, Apache has become the number one Web server for users.

However, in a real production environment, it is still not possible to use the default configuration of Apache directly to act as a server. After all, in order to use Apache server more fully and rationally, we should make some necessary adjustments to Apache's default configuration according to our actual needs. While optimizing the configuration for Apache, it is particularly important to modify the maximum number of concurrent connections for Apache.

Method/Step
  1. 1

    Enable MPM Module configuration file

    We need to enable the configuration file in the httpd.conf file as follows:

    # Server-pool Management (MPM specific) Include conf/extra/httpd-mpm.conf (remove the comment symbol "#" before the line)

  2. 2

    After enabling the MPM module, locate the configuration file for editing.

    There is a configuration file named Httpd-mpm.conf in the Apace installation directory/conf/extra directory. This file is mainly used for the configuration of the MPM module. However, by default, the MPM module configuration file for Apache is not enabled.

    650) this.width=650; "class=" Exp-image-default "alt=" High performance Apache server configuration large Concurrent Tutorial MPM module Configuration "src=" http://h.hiphotos.baidu.com/ Exp/w=500/sign=9d9958a861d0f703e6b295dc38fb5148/d52a2834349b033b4c3ff26516ce36d3d439bddd.jpg "style=" border:0px ; "/>

  3. 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. 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

Precautions
    • Serverlimit represents the maximum number of processes that Apache allows to create. It is worth noting that Apache has a hard limit of serverlimit 20000 at compile time (for Mpm_prefork modules Serverlimit 200000). You can't go beyond that limit. Be especially careful when using this command. If you set Serverlimit to a higher value than you actually need, you will have too much shared memory allocated. If Serverlimit and maxclients are set to exceed the processing power of the system, Apache may not boot or the system will become unstable. Note: When configuring the relevant parameters, first ensure that the server has sufficient hardware performance (for example: CPU, memory, etc.). If you notice that the server's memory footprint increases as the server's running time increases, and perhaps a memory leak occurs in the program, adjust the value of the parameter maxrequestsperchild down to reduce the impact of the memory leak, and then quickly identify the problem in the program.


This article is from the "lake and Laughter" blog, please make sure to keep this source http://hashlinux.blog.51cto.com/9647696/1751159

High performance Apache server configuration large Concurrent Tutorial MPM module configuration

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.