HTTP series --HTTP2.0 new features: binary transmission, multiplexing, Haeder compression, server push, QUIC protocol

Disclaimer: If there is infringement, please contact me, we grow and learn together. STAY CURIOUS. STAY HUMBLE. Https://blog.csdn.net/saucxs/article/details/90322015

I. Introduction

HTTP 2.0 compared to HTTP 1.X, can be said to greatly improve the performance of the web.

 

In HTTP 1.X, for performance reasons, we will introduce Sprite map, a small map inline, using multiple domain names and so on the way. All this is because the browser limits the number of requests under the same domain name, when the page is requested requires a lot of resources when the head of line blocking (Head of line blocking) will result in reaching the maximum number of requests, the remaining resources need to wait other resources to initiate a request after the request is complete.

 

二、HTTP 2.0

Lower than the HTTP 2.0 HTTP 1.X feel in the end how much faster, Address: https://http2.akamai.com/demo

In HTTP 1.X, because of HOL blocking, you will find that this is requested

In HTTP 2.0, because of the introduction multiplexing, you will find that such a request be

 

Three, HTTP 2.0 core

3.1 Binary Transmission

HTTP 2.0 in all core strengthening performance with you in this - binary transport .

The previous version of HTTP, the way we transmit data - text transmission.

HTTP 2.0 is introduced in a new coding scheme, all the data will be transmitted separated, and the system using two encoding formats.

3.2 Multiplexer

In HTTP 2.0, there are two very important concept, namely a frame (Frame) and the flow (stream).

Frame represents the smallest unit of data , each frame identifies the stream to which the frame belongs, the stream is a data stream composed of a plurality of frames.

多路复用,就是在一个 TCP 连接中可以存在多条流。换句话说,也就是可以发送多个请求,对端可以通过帧中的标识知道属于哪个请求。通过这个技术,可以避免 HTTP 旧版本中的队头阻塞问题,极大的提高传输性能。

 

3.3 Header压缩

在 HTTP 1.X 中,我们使用文本的形式传输 header,在 header 携带 cookie 的情况下,可能每次都需要重复传输几百到几千的字节。

在 HTTP 2.0 中,使用了 HPACK 压缩格式对传输的 header 进行编码,减少了 header 的大小。并在两端维护了索引表,用于记录出现过的 header ,后面在传输过程中就可以传输已经记录过的 header 的键名,对端收到数据后就可以通过键名找到对应的值。

 

3.4 服务端push

在 HTTP 2.0 中,服务端可以在客户端某个请求后,主动推送其他资源。

可以想象以下情况,某些资源客户端是一定会请求的,这时就可以采取服务端 push 的技术,提前给客户端推送必要的资源,这样就可以相对减少一点延迟时间。当然在浏览器兼容的情况下你也可以使用 prefetch 。

 

3.5 QUIC

这是一个谷歌出品的基于 UDP 实现的同为传输层的协议,目标很远大,希望替代 TCP 协议。

1、该协议支持多路复用,虽然 HTTP 2.0 也支持多路复用,但是下层仍是 TCP,因为 TCP 的重传机制,只要一个包丢失就得判断丢失包并且重传,导致发生队头阻塞的问题,但是 UDP 没有这个机制

2、实现了自己的加密协议,通过类似 TCP 的 TFO 机制可以实现 0-RTT,当然 TLS 1.3 已经实现了 0-RTT 了

3, support for error correction and retransmission mechanisms (forward recovery), only in the case of a lost packet retransmission is not required, the use of error-correcting mechanisms to recover lost packets. Correction mechanisms : by way of exclusive or calculates the exclusive OR value data sent to and sent a single packet, the server in a case where a packet loss is found, and the other packets by the exclusive OR values calculated by the packet loss packets. On the use of retransmission mechanism in case of lost packets or two more, because not count out.

 

Guess you like

Origin blog.csdn.net/saucxs/article/details/90322015