Reasons why HTTPS is slower than HTTP

HTTPs links are much slower than unencrypted HTTP links.

Both HTTPs links and HTTP links are built on top of the TCP protocol. The HTTP link is relatively simple. After the connection is established using three handshake packets, the content data can be sent.

The client first sends a SYN packet, then the server sends a SYN+ACK packet, and finally the client sends an ACK packet, and then the content can be sent. The sending process of these three packets is called TCP handshake.

Looking at the HTTPs link, it also uses the TCP protocol to send data, so it also requires the three-step handshake process above. And, after these three steps are over, it has an SSL handshake .

HTTP time-consuming = TCP handshake

HTTPs time-consuming = TCP handshake + SSL handshake

 Therefore, HTTPs is definitely more time-consuming than HTTP, which is called SSL latency.

 

The command-line tool curl has a w parameter, which can be used to measure the specific time-consuming of the TCP handshake and SSL handshake. Take Alipay as an example.

$ curl -w "TCP handshake: %{time_connect}, SSL handshake: %{time_appconnect}\n" -so
/dev/null https://www.alipay.comTCP handshake: 0.022, SSL handshake: 0.064

 The w parameter in the above command indicates the specified output format, the timeconnect variable indicates the time-consuming of the TCP handshake, the timeappconnect variable indicates the time-consuming of the SSL handshake, and the s parameter and the o parameter are used to close the standard output.

 

As can be seen from the running results, the SSL handshake (64 milliseconds) is about three times as long as the TCP handshake (22 milliseconds).

That is, during the connection establishment phase, the HTTPs link takes 3 times longer than the HTTP link, the exact number depends on the speed of the CPU.

 

Therefore, if it is an occasion with low security requirements, in order to improve the performance of the web page, it is recommended not to use a digital certificate with high security strength. In general, a 1024-bit certificate is sufficient, and a 2048-bit and 4096-bit certificate will further prolong the SSL handshake time.

 

Go to: http://www.codeceo.com/article/ssl-time-https-slower-http.html

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326945078&siteId=291194637