Summary of HTTP2.0 features

 

Recall HTTP1.1:

1. Long connection

Http1.1 supports persistent connection (PersistentConnection) and request pipeline (Pipelining) processing. Multiple HTTP requests and responses can be transmitted on a TCP connection, reducing the consumption and delay of establishing and closing connections. It is enabled by default in HTTP1.1 Connection: Keep-alive, to a certain extent, makes up for the shortcomings of HTTP1.0 that each request has to create a connection.

2. Cache processing

Introduced more cache control strategies such as Entity tag, If-Unmodified-Since, If-Match, If-None-Match and more optional cache headers to control the cache strategy.

3. Bandwidth optimization and the use of network connection
introduces the range header field in the request header, which allows only a certain part of the resource to be requested, that is, the return code is 206 (Partial Content), which facilitates the free choice of developers for full Utilize bandwidth and connections.
4. Error notification management
Added 24 error status response codes. For example, 409 (Conflict) indicates that the requested resource conflicts with the current state of the resource; 410 (Gone) indicates that a resource on the server is permanently deleted.

5. Host header processing
Http1.1 request message and response message should support Host header field, and if there is no Host header field in the request message, an error (400 Bad Request) will be reported.


HTTP2.0 features

1. Fully use binary format

HTTP2.0 mainly changes HTTP2.0 as a new version of the protocol, and there are bound to be many details of the changes, but for application developers and service providers, there are several major changes .
The new binary format (Binary Format) http1.x was a plaintext protocol when it was born. Its format consists of three parts: start line (request line or status line), header, and body. To identify these three parts, protocol analysis is required. The analysis of http1.x is based on text. The format analysis based on the text protocol has natural defects, and the expression of the text is diversified. There are bound to be many scenarios to consider the robustness. The binary system is different, and only the combination of 0 and 1 is recognized. Based on this consideration, the protocol analysis of http2.0 decided to adopt the binary format, which is convenient and robust.
Some people may think that text-based http debugging is much more convenient. Many tools such as firebug, chrome, charles, etc. can debug modification requests on the fly. In fact, many requests now go to https. To debug https requests, you must have a private key. Most requests of http2.0 should be https, so debugging convenience cannot be a powerful consideration. Tools like curl, tcpdump, wireshark are more suitable for http2.0 debugging.
http2.0 uses the binary format to define a frame, which is compared with the format of http1.x as shown below:

 

2. Multiplexing
According to the id of the request, the request is attributed to different server requests, that is, the data transmission of multiple business units is performed simultaneously on a single connection.
3. Head compression

Assume that a page has 100 resources to load (this number is still quite conservative for today's Web), and each request has a 1kb message header (this is also not uncommon, because of the existence of such things as cookies and references) ), you need to consume at least 100kb to get these message headers. HTTP2.0 can maintain a dictionary and update the HTTP headers by difference, which greatly reduces the traffic generated by header transmission.
The encoder is used to reduce the size of the header that needs to be transmitted, and both parties in the communication each cache a header fields table, which not only avoids the transmission of repeated headers, but also reduces the size that needs to be transmitted.

The headers of HTTP1.X are becoming more and more swollen, and many of them are repetitive and redundant. HTTP2.0 can compress the size of the header and avoid repeated transmission, which can greatly reduce the delay.

4. Server push

Server push can send the resources needed by the client to the client along with index.html, eliminating the need for the client to repeat the request. Because there are no operations such as initiating a request, establishing a connection, etc., static resources can be pushed through the server to greatly increase the speed.

5. Request priority

 


What pain points does the multiplexing of HTTP2.0 solve the long connection multiplexing in HTTP1.X?
HTTP/1.* One request-response, establish a connection, and close it when used up; each request must establish a connection; the
HTTP/1.1 Pipeling solution is that several requests are queued for serialization and single-threaded processing, and subsequent requests wait The return of the previous request can get the execution opportunity. Once a certain request times out, the subsequent request can only be blocked, there is no way, that is, the head of the line blocking that people often call;

In other words, although HTTP1.1 reduces the consumption of TCP connections, it is still executed serially.
Multiple HTTP 2.0 requests can be executed in parallel on a connection at the same time. A certain request task is time-consuming and will not affect the normal execution of other connections;
 

Supplement: HTTP2.0 multiplexing advantage
The key to HTTP performance optimization is not high bandwidth, but low latency. The TCP connection will "tune" itself over time, initially limiting the maximum speed of the connection. If the data is successfully transmitted, the transmission speed will increase over time. This tuning is called TCP slow start. For this reason, the originally bursty and short-term HTTP connection becomes very inefficient.
HTTP/2 allows all data streams to share the same connection, so that TCP connections can be used more effectively, so that high bandwidth can truly serve the performance improvement of HTTP.
 

 

 

 

Guess you like

Origin blog.csdn.net/qq_36807862/article/details/103402831