1) Adjust the value of the configuration item for the profile (httpd.conf)
A Timeout of #建议设置该值比较小 facilitates quick release of the connection.
KeepAlive off #系统前端有安装squid, it must be turned on, otherwise processing dynamic content is many, then close, or handle static more resources, perhaps open.
Maxkeepaliverequests 100
KeepAliveTimeout #KeepAlive超时时间, this value is not specified and is used by default, otherwise this value is used.
Configuring the operating mode 1:PREFORK.C
<ifmodule prefork.c> #多个子进程, each child process has 1 threads, can only maintain 1 connections at a point in time, high efficiency, but consumes memory
Startservers the number of sub-processes that were established at the start of the AA <20 20~50 50~100
Minspareservers the minimum number of idle child processes default 5 quantity is not enough to be created
Maxspareservers 10# The maximum number of idle child processes default 10 redundant processes will be closed
Serverlimit limit value of the number of client requests connected in 1024#apache is 20000 max.
MaxClients 768# allow the number of Client side request connections default to MaxClients and Serverlimit must be increased at the same time serverlimit items must be placed before the MaxClients item
Maxrequestsperchild 0# Each child process can handle the number of requests in its declaration cycle, up to 10000 0 child processes will not end more than 10000, and many child processes will be ended
</IfModule>
The
Setting Maxrequestsperchild to a value other than 0 has two benefits:
1) can prevent (accidental) memory leaks from being carried out indefinitely, thus exhausting memory.
2) gives the process a limited lifespan, which helps reduce the number of active processes when the server load is mitigated.
For keepalive links, only the first request is counted. In fact, it changes the behavior of each child process to limit the maximum number of links.
Threadlimit >= threadsperchild
maxclients <= serverlimit * Threadsperchild must be a multiple of threadsperchild (2048 <= 25*25)
maxsparethreads >= minsparethreads+threadsperchild (>= 25+25)
Configure working mode 2:WORKER.C
< Ifmodule worker.c> #多个子进程, each child process has multiple threads, can only maintain 1 connections at a point in time, does not consume memory, is suitable for high traffic servers, and a single thread crash can cause other threads in the same process to crash
Startservers 3# Number of child processes established at startup
Minsparethreads 25# The minimum number of idle child processes default 5 is not enough to be created
Maxsparethreads #空闲子进程的最大数量 redundant processes are turned off Maxsparethreads>=minsparethreads+threadsperchild
Serverlimit 25#apache The limit value of the number of client-side request connections is maximum 20000
MaxClients 150# allow the number of client side request connections The default maxclients and Serverlimit must be increased by Maxclients<=serverlimit*threadsperchild
Threadsperchild 25# Each child process establishes the number of threads to be executed by default 100~500 maximum value 20000 and threadlimit must be increased at the same time
Threadlimit 200# Maximum number of threads per child process configurable Threadlimit>=threadsperchild
Maxrequestsperchild 0# Each child process has the ability to process maximum requests in its declaration cycle, up to 3000 0 The child process does not end more than 10000, and many of the child processes are ended
</ifmodule>
Set Expiration Time
<ifmodule expires_module.c>
Expiresaction on
ExpiresDefault "Access plus month"
Expiresbytype "text/html Access plus month"
</IfModule>
Turn on gzip compression
<ifmodule mod_deflate.c>
Deflatecompressionlevel 7
Addoutputfilterbytype DEFLATE text/html text/plain text/xml application/x-httpd-php
Addoutputfilter DEFLATE CSS JS
</IfModule>
Apache Performance Tuning Reference