Small knowledge, big challenge! This article is participating in the creation activity of “Essential Tips for Programmers”.
This article has participated in the “Digitalstar Project” and won a creative gift package to challenge the creative incentive money.
The images in this article are from Kobayashi Coding’s graphic network
In addition, if you have encountered the content of the three versions of HTTP protocol in the work/study, you are also welcome to communicate and learn together to deepen the impression of knowledge points ~
This article focuses on navigation
What performance improvements does HTTP/1.1 have over HTTP/1.0?
What is HTTP/2 optimized for HTTP/1.1?
What are the weaknesses of HTTP/2 and what are the optimizations of HTTP/3?
The advantages and disadvantages of the three HTTP protocols are summarized
1. What performance does HTTP/1.1 improve compared to HTTP/1.0?
- [1] TCP’s approach to long connections improves the performance overhead caused by short connections
You can obviously see that the efficiency of the long link is much higher!
Don’t keep setting up and breaking TCP connections!
(Although it is more efficient to eliminate the establishment and disconnection, it is not good to be connected all the time. In order to prevent malicious connections from causing damage to the server, you can limit the maximum number of long connections on the client.)
-
[2] Support pipeline network transmission
-
The first request goes out and you don’t have to wait for it to come back
- Reduce overall response time
-
HTTP/1.1 performance bottlenecks
- Request/response Header is sent uncompressed
- Send lengthy headers
- Slow server response is likely to cause queue head congestion
Queue head congestion is a common problem
- No request priority control
- Requests can only start from the client and the server can only respond passively
2. What is HTTP/2 optimized for HTTP/1.1?
First, HTTP/2 protocol is based on HTTPS, so HTTP/2 security is also guaranteed.
The following optimizations are made for HTTP/2, a performance bottleneck of HTTP/1.1
-
[1] Head compression
- Head compression using the HPack algorithm (see figure above)
-
[2] The message adopts binary format
- This is not friendly to humans, but it is friendly to computers, because computers only understand binary. After receiving a packet, they do not need to convert the plaintext packet into binary, but directly parse the binary packet, which increases the data transmission efficiency.
-
[3] All packets of each request/response are called data streams and each stream is marked with a unique number
-
The client can specify the priority of the Stream and the server will respond to the Stream with the highest priority
- There are theRequest priority controlCan avoid the queue head jam!!
-
-
[4] Use multiplexing to concurrent multiple requests/responses in a single connection
-
You don’t have to go one by one
-
Removed serial requests from HTTP/1.1 without queuing!
- Can avoid the queue head blocking problem
- Can reduce latency
- You can dramatically increase connection utilization!
-
-
[5] Improved the traditional “request-reply” mode of the server can actively send messages to the client! (Server push)
- For example, when the browser just requests HTML, it proactively sends static resources such as JS and CSS files that may be used to the client in advance to reduce the delay. This is also known as Server Push (also called Cache Push).
3. What are the weaknesses of HTTP/2 and what are the optimizations of HTTP/3?
The main problem with HTTP/2 is that multiple HTTP requests are multiplexing a TCP connection, and the underlying TCP protocol does not know how many HTTP requests there are. So once packet loss occurs, TCP’s retransmission mechanism is triggered, so all HTTP requests in a TCP connection must wait for the lost packet to be retransmitted.
- In HTTP/1.1, if a single request is blocked in transit, all the post-queue requests are blocked
- HTTP/2 Multiple requests reuse a TCP connectionOnce,Lose the packageThat will beBlocks all HTTP requests.
This is all based on the TCP transport layer, so HTTP/3 changes HTTP’s underlying TCP protocol to UDP
UDP occurs regardless of the order and regardless of packet loss, so there will be no HTTP/1.1 queue header blocking and HTTP/2 a lost packet all retransmission problems
We all know that UDP is not reliable transmission, but based on UDP QUIC protocol can achieve similar to TCP reliable transmission.
- QUIC has its own set of mechanisms to ensure the reliability of transmission. When packet loss occurs in a stream, only this stream is blocked, and other streams are not affected.
- TLS3 has been updated to version 1.3, and the header compression algorithm has also been updated
QPack
- HTTPS takes six interactions to establish a connection,First three handshakes are established.Then the TLS/1.3 three-way handshake.QUICdirectlytheIn the pastTCP and TLS / 1.3 的 Six interactions merge into three, reducing the number of interactions
So, QUIC is a pseudo-TCP + TLS + HTTP/2 multiplexing protocol on top of UDP.
However – QUIC is a new protocol, for many network devices, do not know what is QUIC, only as UDP, which will cause new problems. So HTTP/3 is now very slow to become popular and it is not known if UDP will be able to reverse TCP in the future
The advantages and disadvantages of the three HTTP protocols are summarized
-
HTTP/1
-
HTTP / 1.0
- Poor safety
- Performance is poor
-
HTTP / 1.1
- Long connections improve performance
- Pipeline network transport (long connections make pipelines possible) improves performance
-
HTTP / 1.1
- Poor safety
- Performance is poor
-
-
HTTP/2
-
advantages
-
Fully compatible with HTTP/1.1
-
Is more secure HTTP faster HTTPS
-
HTTPS based security is guaranteed!
-
Solve HTTP/1.1 performance bottlenecks Take full advantage of bandwidth reduce latency greatly improve the online experience!
- [1] Use HPack algorithm to achieve head compression;
- [2] Message format is binary;
- [3] All packets of each request/response are called data flow perThe data flowStreams are marked with a unique number and priorities can be specified;
- [4] Multiplexing technology;
- [5] Server push;
-
-
-
disadvantages
-
Multiple HTTP requests are multiplexing a TCP connection, and the underlying TCP protocol does not know how many HTTP requests there are.
So once packet loss occurs, TCP’s retransmission mechanism is triggered, so all HTTP requests in a TCP connection must wait for the lost packet to be retransmitted
-
- In HTTP/1.1, if a single request is blocked in transit, all the post-queue requests are blocked.
- HTTP/2 multiple requests reuse a TCP connection, which blocks all HTTP requests once packet loss occurs.
This is all based on the TCP transport layer, so HTTP/3 changes the HTTP layer TCP protocol to UDP!
-
-
HTTP/3
-
advantages
-
Solve transport layer problems (using UDP+QUIC protocol)
- UDP occurs regardless of the order and regardless of packet loss, so there will be no HTTP/1.1 queue header blocking and HTTP/2 a lost packet all retransmission problems
- QUIC is a pseudo-TCP + TLS + HTTP/2 multiplexing protocol on top of UDP. The protocol is HTTP/3 bottom support protocol based on UDP and take the essence of TCP to achieve fast and reliable protocol
-
-
disadvantages
- QUIC is a new protocol, for many network devices, do not know what is QUIC, only as UDP, which will cause new problems. As a result, HTTP/3 is now very slow to gain popularity.
-