Optimization of Apache under Windows

Source: Internet
Author: User

Optimization of Apache under Windows(2012-06-02 13:00:35) reproduced (1) Preferred to view Apache working mode
View Apache's working mode command under Windows: Httpd-l
If MOD_WIN32.C is listed, it means that win32.c works. The full list of contents is as follows:
Core.c
Mod_win32.c
Mpm_winnt.c
Http_core.c
Mod_so.c

MPM_WINNT.C is dedicated to Windows NT-optimized MPM (multi-processing module), which uses a separate parent process to produce a separate subprocess that, in turn, produces multiple threads in this subprocess to process requests. This means that mpm_winnt can only start a parent-child two process and not start multiple processes at the same time as Linux.
Mpm_winnt mainly through the Threadsperchild and maxrequestsperchild two parameters to optimize Apache, the following detailed to explain.

(2) mod_win32.c working mode, the corresponding optimization content as follows
In the httpd.conf file, add the following:
<ifmodule mpm_winnt.c>
Threadsperchild 250
Maxrequestsperchild 5000
</IfModule>

Threadsperchild
This parameter sets the number of threads per process, and the child processes are no longer establishing new threads when they are established at startup. On the one hand, because mpm_winnt cannot start multiple processes, this value should be large enough to handle possible peaks of requests; On the other hand, this parameter is based on the response speed of the server, and the number is too large to slow down. Therefore, it is necessary to synthesize a reasonable numerical balance.

The default value on Mpm_winnt is 64, and the maximum value is 1920. This is recommended to be set to 100-500, the server performance is higher, the value is larger, the inverse value is smaller.

Maxrequestsperchild
This parameter represents the maximum number of requests that each subprocess can handle, that is, the number of child processes at the same time. Set to zero for unlimited, the default value on Mpm_winnt is 0.
The official reference manual is not recommended to be set to 0, mainly based on two points of consideration:
(1) can prevent (accidental) memory leaks indefinitely, thus exhausting memory;
(2) Give the process a limited lifespan, thus helping to reduce the number of active processes when the server load is reduced.

The value of this parameter depends largely on the memory of the server and can be set to 0 or a large number if the memory size is large, otherwise a small amount is set. It is necessary to note that if this value is set too small will cause the Apache to restart frequently, in the log file will see the following text:
Process exiting because it reached Maxrequestsperchild. Signaling the parent

This reduces the overall performance of Apache.

Alternatively, you can verify that the currently set value is reasonable by looking at the Server-status (status report) provided by Apache and open it in the httpd.conf file as follows:

* # First need to load the Mod_status module
LoadModule Status_module modules/mod_status.so
* # Then set the access address
<Location/server-status>
SetHandler Server-status
Order Deny,allow
Deny from all
# If an IP access limit is set to allow from 192.168.0.1
Allow from all
</Location>

Open the following address: http://localhost/server-status, check Apache operation!

Optimization of Apache under Windows

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.