1, the concept and advantages of keepalive
The keepalive of HTTP is a long connection between the browser and the server, and this connection can be reused. When the client sends a request, after receiving the corresponding content, the connection will remain for a period of time, in which time the second will not need to re-establish the connection, you can directly use this connection to send the request, greatly improve the speed.
2, the disadvantage of keepalive
is not all the website should open keepalive. The answer is certainly not. KeepAlive increase the efficiency of access, but also increase the pressure on the server.
3, Apache configuration keepalive
Apache controls the KeepAlive by configuring KeepAlive and KeepAliveTimeout, with specific parameters as follows:
KeepAlive On/off (can be set to open on or off)
KeepAliveTimeout 10 (Persistent connection hold time, to time will be broken link)
4, Case description (source of the Internet):
Suppose the KeepAlive timeout is 10 seconds, server processing 50 independent user access per second, then the total number of Apache in the system is 10 * 50 = 500, if a process occupies 4 m memory, then a total of 2G memory consumption, so you can see that in this configuration, the phase When memory is consumed, the advantage is that the system handles only 50 times of TCP handshake and shutdown operations.
If KeepAlive is turned off, or if 50 users per second are accessed, if the user's number of consecutive requests is 3, then the total number of Apache process is 50 * 3 = 150, if the total memory consumption of 4 m memory, then the overall amount of RAM 600M, this configuration can save a lot of memory, However, the system handles 150 times of TCP handshake and shutdown operations, and therefore consumes a little more CPU resources.
5, summary
(1) If the memory and the CPU are sufficient, turn on and off the keepalive has little impact on performance.
(2) If you consider the server pressure, if it is a static page, a large number of calls to JS or pictures, it is recommended to open keepalive; if it is a Dynamic Web page, it is recommended to close keepalive.