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 a Web server that ranks the number of users in the list. 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.

MPM is Multi-Processing Modules, which represents the multi-processing module in Apache, and currently includes three modes in apache2.2/2.4 on Linux: Prefork, worker, and event mode. The command parameter "-L" of Apache or httpd lists the modules that have been compiled in the current Apache, since MPM can only specify one at compile time, so there are only 1 mpm in the static module listed, as follows:

See what mode of work
Httpd-l

Modify the Apache configuration file (rpm installation mode)
<ifmodule prefork.c>
Startservers 8
Minspareservers 5->8
Maxspareservers 20
Serverlimit 256->500
MaxClients 256->500
Maxrequestsperchild 4000->10000
</IfModule>

Restart Apache Service
/ETC/INIT.D/HTTPD restart

Specific explanations:
Startservers
Number of child processes created when Apache was started. Recommended settings: small = default in =20~50 large =50~100

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. Recommended settings: Consistent with Startservers

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. Recommended settings: Small =20 =30~80 Big =80~120

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. Recommended setting: =500~1500 large =1500~3000 in small =500

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. Recommended settings: Consistent with MaxClients

Maxrequestsperchild
Recommended settings: Small =10000 medium or large =10000~500000

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.