Introduction
Many friends may still be immersed in the world of HTTP 1.1 and cannot extricate themselves, but the torrent of the times has led us to the world of HTTP3. Yes, you are watching the scenery on the bridge, and someone on the house next to the bridge is watching you.
In order not to be abandoned by the times, today I will explain to you the new features of HTTP3.
Introduction to HTTP Growth
The full name of HTTP is Hypertext Transfer Protocol, which is the application layer transfer protocol on which the World Wide Web is based. The original version was HTTP 0.9, which was produced in the late 1980s, and was later upgraded to 1.0 in 1996.
But HTTP1.0 cannot meet the growing material and cultural needs and yearning for a better world. So HTTP 1.1 appeared in 1997, and then until 2014, HTTP 1.1 has been updated.
Then in 2015, a new HTTP2 protocol was developed based on Google's SPDY project in order to meet the needs of fast-delivered web applications and modern browsers.
After another 4 years, in 2019, Google has developed a new protocol standard QUIC protocol, which is the cornerstone of HTTP3, and its purpose is to improve the speed and security of user interaction with websites and APIs.
Problems solved by different HTTP protocols
Different HTTP protocols solve different problems. What are the problems with HTTP 1.1?
- Because the data in an HTTP1.1 connection is transmitted sequentially, there will be a head-of-line blocking problem. If the previous is a large data packet, it will cause the subsequent data packet to be blocked.
- HTTP1.1 cannot compress request headers and cookies, so the transmission efficiency will be relatively low.
- In order to ensure that the buffer does not overflow, HTTP1.1 has a TCP slow start function. As a congestion control measure, the protocol repeatedly probes the network to calculate the available capacity, but this will cause multiple data transmissions, resulting in message delays .
For HTTP2, it uses binary for message transmission and splits the message into individual streams. The stream contains multiple frames, allowing resources to be sent using the same connection through multiplexing, which solves the line header blocking It also supports data packet priority and server push.
However, HTTP2 server push will complicate the application, and the problem of TCP-level header blocking may still occur when the data packet is lost and must be resent in the correct order.
It should be noted that HTTP/2 is an extension of HTTP/1.1, not a substitute for it. The application semantics remain the same, with the same HTTP method, status code, URI, and header fields. So HTTP/2 can be used wherever HTTP/1.1 is used.
HTTP/2 uses a single TCP connection between the client and the server, which remains open during the interaction.
Although HTTP/2 supports concurrency, too much concurrency will cause the HTTP/2 server to receive a large number of requests, resulting in request timeouts.
HTTP3 and QUIC
The goal of HTTP/3 is to provide fast, reliable, and secure Web connections on all types of devices by solving the transmission-related problems of HTTP/2. To this end, it uses a different transport layer network protocol called QUIC, which was originally developed by Google.
With emotion, although China has made some progress in the application of the system recently, looking at these underlying agreements, they are all made by foreigners.
The fundamental difference between HTTP/2 and HTTP/3 is that the bottom layer of HTTP/2 uses the TCP protocol, while the bottom layer of HTTP/3 uses QUIC, and the bottom layer of QUIC uses the UDP protocol.
Let's take a look at the protocol stack comparison between HTTP/2 and HTTP/3:
The TCP protocol mainly guarantees the reliability and orderly delivery of services, but TCP requires a handshake to establish a connection. This is to ensure that both the client and the server exist and they are willing and able to exchange data. However, it also requires a complete network round trip to complete before any other operations can be completed on the connection. If the client and server are far apart, it will take more time to connect.
We know that UDP is connectionless, so it is much simpler than TCP. It does not require TCP to establish multiple connections, and only needs to send data packets out.
Therefore, the advantage of using QUIC is that it reduces the delay of the system and is suitable for situations where some data packet loss can be tolerated, such as online games, advertising bidding, online video, real-time streaming, and so on.
In addition, because UDP supports broadcasting, HTTP3 is also suitable for broadcasting applications, such as precise time protocol and routing information protocol.
In addition, HTTP3 can also be used in the Internet of Things, big data, and VR.
Since HTTP3 uses the QUIC protocol, what exactly is QUIC?
Generally speaking, QUIC is a general transport protocol, very similar to TCP. Why create a new set of agreements? This is because the existing TCP protocol is very difficult to expand, because too many devices have used various versions of the TCP protocol. It is very difficult to directly extend the existing TCP protocol because of the need It is almost impossible to upgrade so many devices.
So QUIC chose to build on top of the UDP protocol. QUIC uses UDP mainly because it hopes to make HTTP/3 easier to deploy, because it has been known and implemented by all devices on the Internet.
QUIC actually rewrites the functions of TCP on the basis of UDP, but it is smarter than TCP and realizes the core functions of TCP more efficiently.
Next, let's take a look at the specific features of QUIC.
TLS1.3
TLS is mainly used to ensure the data security of the client and server in the data transmission process, and can encrypt and transmit plaintext data. TLS1.3 is the latest version of the TLS protocol. In the old version such as TLS1.2, the handshake between the client and the server requires at least two network round trips, but in TLS1.3, it is reduced to only one round trip.
Although the unencrypted transmission mode is supported in HTTP/2, all modern browsers do not support this mode by default, so HTTP/2 must be used with HTTPS. In the long run, HTTPS is definitely the future trend, so in QUIC, the TLS 1.3 protocol is directly used. QUIC itself encapsulates TLS1.3.
The advantage of this is that QUIC cannot run plaintext, so it is more secure. And QUIC has a built-in encryption protocol, which combines transmission and encryption handshake into one, saving round trips.
Because QUIC is encrypted all the way, for some ISPs and intermediate networks, network data can no longer be analyzed and counted, so its use may be restricted. And because QUIC encrypts each data packet separately, in the case of high concurrency, it may cause performance problems.
Solve HoL blocking
The traditional HTTP1.1 and HTTP2 underlying protocol is TCP, although HTTP2 can split the data of different files into one stream at the application layer for transmission in the same connection. But for TCP itself, it does not know that these streams belong to different files, and it treats them as the same file. So if the sending data packet is lost, TCP will resend all file packets. This leads to the problem of HOL blocking.
QUIC is a little more fine-grained, and it can perform packet loss detection and recovery logic on a per-flow basis. Thus, only the failed stream will be retransmitted, not the entire file.
Connection migration
In TCP, if I want to establish a connection between the client and the server, I need to know these 4 elements: client IP address + client port + server IP address + server port.
If one of these 4 elements sends a change, the TCP connection needs to be re-established. And need to restart the operation in the process according to the application-level protocol.
For example, if you are downloading a large file, but the network address changes suddenly, you may need to request the file again.
To solve this problem, QUIC introduced a concept called connection identifier (CID). Each connection is assigned an additional number among the above 4 elements to mark the unique connection between the client and the server.
Because this CID is defined by QUIC, it will not change with changes in network migration. There is no need for a new handshake. This situation is called connection migration.
Summarize
Well, today’s HTTP/3 and QUIC are introduced here. Although we have not covered more details of the underlying layer, I believe everyone should understand it. To sum up, QUIC actually works on top of the UDP protocol. Recreated a more advanced and effective TCP protocol.
This article has been included in http://www.flydean.com/03-http3/
The most popular interpretation, the most profound dry goods, the most concise tutorial, and many tips you don't know are waiting for you to discover!
Welcome to pay attention to my official account: "Program those things", know technology, know you better!
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。