Apache server is particularly slow first visit to the settlement process, php environment

Before loading a server is a java tomcat apache project,

Later installed a phpstudy above, the project found that access php open web browser for the first time need 7-8 seconds, continuous access to open after successful very quickly, over a period of time to visit is 7-8 seconds only to open the page again and again

The solution is to modify the apache configuration, repair and dns server is 114.114.114.114

Solution is as follows,

the Apache files to control the number of threads http-mpm.conf, following in the conf / exrtra directory (My Documents directory to D: \ wamp \ bin \ apache \ Apache2.4.4 \ conf \ extra), make the function requires a configuration file # removed before httpd.conf will Include conf / extra / httpd-mpm.conf , so that the http-mpm.conf effect.
On Windows systems, work is the Winnt mpm section, search mpm_winnt_module
the
<IfModule mpm_winnt_module> 
    ThreadStackSize        8388608 
    ThreadsPerChild        150 
    MaxConnectionsPerChild   0 
</IfModule> 

changed to

<IfModule mpm_winnt_module>
  ThreadStackSize 838860
  ThreadsPerChild 450
  MaxConnectionsPerChild 3000
</IfModule>

Reboot the server to test!

Special Note: If a project please remember to replace 127.0.0.1 localhost 

And should also modify httpd-default.conf timeout settings to match.
Removed in httpd.conf Include conf / extra / httpd-default.conf # before that the httpd-default.conf effect.
Wherein the following parameters are regulated
Timeout 15 (default connection timeout 300, too, will be reduced while reducing the number of connections, i.e., occupied by the actual number of threads above)
the KeepAlive the On (open performance can be improved, because a plurality of page requests typically have )
MaxKeepAliveRequests 50 (this number is adjusted according to their own web content)
KeepAliveTimeout. 5 (this line is less than Timeout)


finally to restart apache.


ThreadStackSize instruction processing stack size for threads client connections (in bytes). The syntax is: ThreadStackSize size, in the NetWare system default value 65536; other systems, the operating system is equal to the default value.
ThreadStackSize process instruction sets the maximum client connections (including to assist in call processing module) allows the use of a thread stack size (bytes). In most cases, the operating system default stack size is reasonable, but in some cases, need to adjust this value. For example, in the default stack size of the smaller platforms (such as HP-UX), Apache might use some third-party modules require a large stack size of crashes. Such problems can be ThreadStackSize set to a large value to solve. The case of this adjustment should only be provided by a third-party module only needs explicitly requested, or by determining the diagnosis is due to stack space is too small to cause a crash. 
And on some platforms, if the default stack space is greater than the space required for the server is running, then ThreadStackSize value to less than the operating system default allows the maximum number of threads per process allows the generation increases. This type of adjustment should be used only in a test environment, and adequate testing of all server processes, because the process of some rare request requires a large stack space. A small server configuration change is likely to make the current set ThreadStackSize become inappropriate.

ThreadsPerChlid is the number of threads Apache child process, this directive sets the number of threads per child process established. After the child process to establish these threads at startup no longer build a new thread. If you are using a similar mpm_winnt only one child mpM process, this value should be large enough so that you can deal with possible requests peak. If you are using a similar worker multiple children of mpM, the total number of threads per child process have to be large enough so that you can deal with possible requests peak.
This parameter needs to be adjusted according to real-time monitor the situation apache-status, so the General Assembly led to rapid growth in memory until the server crashes, is too small will cause the server connection queue fills in the peak period, resulting in slow connection site. At the same time we should modify the timeout setting another configuration file httpd-default.php to cooperate in this parameter.
For mpm_winnt, the default value is 64 ThreadsPerChild; 25 mpM other.
MaxRequestsPerChild is the largest number of requests processes, refers both to the cache site received several requests. Set too small will affect server performance, because it will take up more cpu time, it will take up too much memory resources. General large number of documents are thousands of websites, so administrators should be set according to their own site conditions.
MaxRequestsPerChildInstruction Set each child in their lifetime to allow the maximum number of requests servo. After reaching the limit MaxRequestsPerChild, the child process will end. If MaxRequestsPerChild is "0", the child process will never end.
Defaults on mpm_netware and mpm_winnt is "0."
The MaxRequestsPerChild set to a nonzero value has two advantages:
A) can be prevented (accidental) for unlimited memory leak to run out of memory.
b) to process a limited life, thus helping reduce the server load when the time to reduce the number of active processes.
Note: For KeepAlive link, only the first request will be counted. In fact, it changes each sub-process limit on the maximum number of links behavior.

==================================================================END==============================================================================

Source: https://zvv.me/xx-jingyan-jiqiao/655.html
refer to the article  http://www.piaoyi.org/php/Windows-Apache-mpm_winnt_module.html

Linux may reference http: // www. elmerzhang.com/2007/11/apache-web-response-slowly/

 

Guess you like

Origin www.cnblogs.com/pxjbk/p/11490588.html