Keep-alive settings of HTTP Services

Source: Internet
Author: User

Like Apache, many HTTP Services provide the keep-alive function, such as keepalive_timeout in nginx configuration.

As for what is keep-alive, Simply put:

Keep-alive maintains the link established by the client on the server. When the client connects to this server again next time, you do not need to re-establish the link and continue to use the previous link.

I will not introduce it here. You can Google it on your own. Let's talk about how to set keep-alive.

Because it will keep the open link, it is applicable to Web scenarios where the same client needs to be linked repeatedly in a short time, for example:

  1. When opening a page, the page links n images, n js scripts, n css, and so on, and all these things are on a server;
  2. Users need to wander around the website frequently;
The former can set a shorter timeout time, for example, 5 seconds; the latter can be a little longer, for example, 60 seconds. So what about keep-alive? In addition to the opposite situations above, you can also turn off it in some special cases. For example, in the case of high concurrency. Why? When too many client requests come, the number of connections to the server is limited. If too many connections are maintained for some users, other users cannot connect to the server normally.

Therefore, we need to release the communication link as soon as possible to free up resources for other clients.

Although frequent connection establishment will consume a certain amount of CPU and memory, the bottleneck of the front-end server is usually not in the current machine performance, but in the number of connections and I/O.

Therefore, in general, you do not need to enable keep-alive on the Web server, or set a lower value. In this way, the machine performance can be fully utilized to improve concurrency. Unless your CPU and memory are tight.

In addition, if the communication between the backend server and the server is HTTP, you should enable keep-alive at this time. Do you say yes :)

----------------------------------------- I am a split line ----------------------------------------------

Additional reading:

Http://blog.netzhou.net /? P = 141

Http://mylinux.5d6d.net/thread-919-1-1.html

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.