is the keepalive of HTTP open or closed?

Source: Internet
Author: User

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.


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.