找回密码
 立即注册
connection连接theHTTP | 软件工程 2022-04-27 240 0star收藏 版权: . 保留作者信息 . 禁止商业使用 . 禁止修改作品
第十四讲我提到了HTTP的性能,用六个字来概括:“还不错,还不够好”。同时,我也谈到了“线头阻塞”,但由于时间关系,我没有详述。这一次,我们来好好看看HTTP在连接中的表现。
HTTP 连接管理也可以算是一个“老掉牙”的话题。您一定听说过“短连接”和“长连接”等术语。今天就让我们一起来澄清一下。
短接
HTTP协议原本(0.9/1.0)是一个非常简单的协议,通信过程也采用了简单的“请求-响应”方式。
它的底层数据传输是基于TCP/IP的,发送请求前需要与服务器建立连接,收到响应消息后立即关闭连接。
因为客户端和服务端的整个连接过程很短,不与服务端保持长期的连接状态,所以称为“短时连接”。早期的 HTTP 协议也被称为“无连接”协议。
短连接的缺点是相当严重的,因为在 TCP 协议中,建立和关闭连接是非常“昂贵”的操作。与TCP建立连接,必须有“第二次握手”,发送3个数据包需要1个RTT;关闭连接是“四挥手”,4个数据包需要2个RTT。
HTTP的一个简单的“请求-响应”通常只需要4个数据包,如果不计算服务器内部的处理时间,最多也就是2个RTT。这样一来,浪费的时间是“3÷5=60%”,三分之二的时间被浪费了,传输效率低的惊人。

(In Lecture 14, I mentioned the performance of HTTP, which can be summarized in six words: "not bad, not good enough". At the same time, I also talked about "thread blockage", but due to time, I didn't elaborate. This time, let's take a good look at the performance of HTTP in the connection.HTTP connection management can also be regarded as an "old-fashioned" topic. You must have heard the terms "short connection" and "long connection". Let's clarify it today.Short circuitHTTP protocol (0.9 / 1.0) was originally a very simple protocol, and the communication process also adopted a simple "request response" mode.Its underlying data transmission is based on TCP / IP. Before sending a request, it needs to establish a connection with the server and close the connection immediately after receiving the response message.Because the whole connection process between the client and the server is very short and does not maintain a long-term connection with the server, it is called "short-term connection". The early HTTP protocol was also called "connectionless" protocol.The disadvantage of short connection is quite serious, because in TCP protocol, establishing and closing connection is a very "expensive" operation. To establish a connection with TCP, there must be a "second handshake", and one RTT is required to send three packets; Closing the connection is "four waves", and two RTTS are required for four packets.A simple "request response" of HTTP usually requires only 4 packets. If the processing time inside the server is not calculated, the maximum is 2 RTTS. In this way, the wasted time is "3 ÷ 5 = 60%", two-thirds of the time is wasted, and the transmission efficiency is surprisingly low.)

[下载]08551494412.rar
[下载]08551527041.rar
[下载]08551540191.rar
[下载]08551521441.rar
[下载]08551573342.rar
[下载]08551611865.rar




上一篇:《 写给大家看的CSS书(第2版) 》.pdf
下一篇:《JAVASCRIPT完全自学手册》.pdf