Make a summary every day, persistence is victory!

/** @date 2021-07-08 @description HTTP/2.0 multiplexing */Copy the code

One (sequence)

HTTP/2.0 is faster, simpler, and more stable than HTTP/1.x. The specific differences are as follows:

  1. HTTP / 2.0Binary protocolHTTP/1.x is a text protocol
  2. HTTP / 2.0The first compression
  3. HTTP / 2.0 introducedmultiplexing
  4. HTTP / 2.0 introducedPush function

Today is a brief summary of multiplexing

Ii (Persistent Connection and Pipelining)

Persistent connection:

In the original version of HTTP, TCP was connected/disconnected every time HTTP communication was conducted. In HTTP/1.1 and some HTTP/1.0, persistent connections were implemented, that is, only one TCP connection was required. In subsequent communication, as long as neither end explicitly indicated that the connection was disconnected, The HTTP communication will always be based on this TCP connection

Pipework: The implementation of persistent connections makes pipework possible, whereas previously HTTP had to wait for the last request to complete before making the next one, pipework enables concurrent requests

Inadequate:

Persistent connections and pipelining reduce the overhead of TCP repeated connections, making the request and response process faster

However, there are also disadvantages, that is, although the request can be sent in parallel, it still needs to wait for the completion of the previous request before processing the next request. If the first request takes too long, the queue head will be blocked.

Second, browsers are limited in the number of requests they can send in parallel at a time, which is about 6-8 based on the browser-based implementation

Three (multiplexing)

HTTP/2.0 implements multiplexing to solve the above problems, as follows:

HTTP/2.0 is a binary protocol, so the transmission is binary frames, and to a TCP connection set up multiple streams, is multiplexing, multiple requests can be communicated through these streams, and both ends can be identified by the frame identity belongs to which request, so that can greatly improve the transmission performance.