Calculating Network Review---HTTP2.0

Multiplexing

Many times our client and server need to communicate frequently. At this time, before Http0.9, that is, there is no long connection, we can only establish a TCP connection once without communication, and the communication is disconnected. At this time, a lot of resources will be wasted. And it took quite a long time.

So the KeepAlive long connection is introduced. In a certain period of time, the same domain name requests data multiple times, and only one TCP connection is established, and all requests reuse this connection. Then frequent connections and disconnections are avoided. But he still has two efficiency problems:

  1. Serial file transfer: When requesting a file, b file can only wait, waiting for a file to connect to the server, the server processes the file, and the server returns the file before they can transfer b.
  2. Too many connections: When there are too many connections, you can only wait for the processing of the previous request to complete before continuing.

So in HTTP2, the concept of multiplexing is introduced, so how does it solve it:

  • Regarding the first question, in HTTP1.1, the transmitted data is based on text, so all data must be transmitted in order. For example, helloworld can only be transmitted from h to d one by one, not in parallel, because the receiving end Don't know the order.
    HTTP2 introduces the concept of binary data frames and streams, where the frame identifies the sequence of the data, so that the data can be reorganized in sequence after the receiving end receives the data, and officially because of the sequence, the server can transmit data in parallel. This is what Liu does.
    A frame represents the smallest unit of data. Each frame will identify which stream the frame belongs to. A stream is a data stream composed of multiple frames.

  • Regarding the second question, because HTTP2 is flow-based for all requests under the same domain name, that is, no matter how many files the domain name accesses, only one connection can be established.

Request priority

You can specify the priority of each Request, so that important requests will be responded to first.

Header compression

Server push

The server can actively send data

Guess you like

Origin blog.csdn.net/why1092576787/article/details/114792087