Measure the Speed Difference Between Http2 and Http3
目录
Software translation.
Background
Http3 is the latest version of the HTTP protocol, which has undergone a significant improvement by using the QUIC (Fast UDP Network Connection) protocol at the transport layer to enhance performance, especially in high packet loss networks.
Http3 will be officially standardized in 2022, and currently mainstream programming language standard libraries do not support http3.
Due to the open-source libraries github.com/quic-go/quic-go/http3 available in the Go language, it is easy to build http3 clients and servers, making it easier to measure the speed difference between http2 and http3.
Measurement method
First, send 200 http2 requests at a speed of no more than 10 times per second, then send 200 http3 requests at a speed of no more than 10 times per second, and measure the average time it takes for requests to be sent and responses to be read.
Because TLS1.3 has a 0-RTT reconnection mechanism and QUIC enforces the use of TLS1.3, although http2 allows non encrypted transmission, only http2 encrypted with TLS1.3 is measured.
At the same time, there is a theoretical difference of one RTT between the first connection and reconnection.
RTT is the round-trip time, which represents the time it takes for data to travel back and forth between the client and server. Its time is related to the speed of webpage loading.
In order to demonstrate the differences between http2 and http3 as much as possible, the above measurement method is used to mainly measure the speed of reconnection.
The source code of the measurement tool can be found in benchhttp2and3
Measurement preparation
The server hardware used for measurement is located in the United States, approximately 12000 kilometers away. It is charged by the hour, rounded to about 3 cents RMB per hour, and uses IPv6. The RTT for accessing from China at night is approximately 240-260ms.
Deploy the same server software locally at the same time.
Use AdGuardHome to modify DNS records, thereby changing whether accessing VPS or local machine.
Measurement results
On the local network, http2 takes over 3ms and http3 takes over 1ms, resulting in a reduction of approximately 50% in reconnection time.
When accessing websites on remote servers based on actual conditions, it takes slightly over 300ms for http2 at night and 270ms for http3. During the day, it takes slightly over 330ms for http2 and 300ms for http3.
The test results show that http3 reduces website usage by about 10% compared to http2 in real website visits.
Subsequent
Can modify the measurement method to determine if the speed difference between the first connection to http2 and http3 have truly 1 RTT.