Configuration optimizations for Apache

Source: Internet
Author: User

"How Apache Works"

Prefork Mode (default)
This multi-path processing module (MPM) implements a non-threaded, pre-derived Web server that works in a similar way to Apache 1.3. It is suitable for systems that do not have a thread-safe library and need to avoid threading compatibility issues. It is the best mpm to require each request to be independent of each other, so that if a request has a problem it will not affect the other request.

This MPM has a strong self-tuning capability and requires very little adjustment of the configuration instructions. The most important thing is to set the maxclients to a value that is large enough to handle the potential request spikes, and not too large to use more memory than the size of the physical memory.

Worker Mode
This multi-path processing module (MPM) enables a network server to support mixed multithreaded multi-process. Because a thread is used to process requests, a large amount of requests can be processed, while the overhead of system resources is less than the process-based MPM. However, it also uses a multi-process, with each process having multiple threads to obtain the stability of the process-based MPM.

"Apache Configuration parameter Notes"
1. KeepAlive on/Off
KeepAlive refers to keeping the connection active, similar to the permanent connection of MySQL. In other words, if keepalive is set to on, then requests from the same client do not need to be connected again, to avoid the burden of adding a new connection to the server each time it is requested. In general, sites with more pictures should have keepalive set to ON.

2, KeepAliveTimeout number
If the time between the second request and the first request exceeds KeepAliveTimeout, the first connection is interrupted and a second connection is created. Its settings generally consider the picture or JS and other files two times the request interval, my setup experience is 3-5 seconds.

3, Maxkeepaliverequests 100
The maximum number of requests for HTTP requests that can be made for a single connection. Setting its value to 0 will support unlimited transfer requests within a single connection. In fact, there is no client program that requests too many pages in a single connection and usually does not reach this limit to complete the connection.

4, Startservers 10
Sets the number of child processes that are established when the server starts. Because the number of child processes dynamically depends on the weight of the load, it is generally not necessary to adjust this parameter.

5, Minspareservers 10
Sets the minimum number of idle child processes. 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. Setting this parameter too large is usually a bad idea.

6, Maxsparethreads 75
Sets the maximum number of idle child processes. If there are currently more than maxspareservers of idle child processes, the parent process kills the extra child processes. This parameter needs to be adjusted only on very busy machines. Setting this parameter too large is usually a bad idea. If you set the value of this directive to be smaller than Minspareservers, Apache will automatically modify it to "Minspareservers+1″."

7, Serverlimit 2000
Maximum number of processes allowed to be configured by the server. Use only if you need to set MaxClients to a value above the default of 256. You want to keep the value of this directive the same as maxclients. Modifying the value of this directive must stop the service completely before starting to take effect, and restarting in restart mode will not take effect.

8, MaxClients 256
The maximum number of requests for a servo client request (maximum number of child processes), and any requests exceeding the maxclients limit will enter the waiting queue. The default value is 256, and if you want to increase this value you must also increase the value of serverlimit. I recommend that you set the initial value to (the maximum physical memory in megabytes/2), and then dynamically adjust according to the load situation. For example, a 4G memory machine, then the initial value is 4000/2=2000.

9, Maxrequestsperchild 0 Apache.exe process includes a parent process, a child process, the parent process receives the access request, the request is referred to the child process processing. Maxrequestsperchild This instruction sets the number of requests that a separate subprocess will be able to process.  After processing the "Maxrequestsperchild number" request, the child process will be terminated by the parent process, the memory occupied by the child process is freed, and if there is another access request, the parent process will re-generate the child process to process. If the Maxrequestsperchild default is set to 0 (infinity) or a larger number (for example, more than 10000), you can make each subprocess handle more requests, not because the child process is constantly terminating, and the sub-processes are started to reduce access efficiency, but Maxrequestsperchild is set to 0 o'clock. If you use 200~300m memory, you will not be able to reduce the amount of memory that is consumed when you load it. Servers with large memory can be set to 0 or larger numbers. Servers with smaller memory may wish to be set to 30, 50, 100 to prevent memory overflow. So in general, if you find the server's memory line up, it is recommended that you try to modify the parameter.

Configuration optimizations for Apache

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.