HTTP vs HTTPS performance

后端 未结 22 2004
说谎
说谎 2020-11-22 10:30

Are there any major differences in performance between http and https? I seem to recall reading that HTTPS can be a fifth as fast as HTTP. Is this valid with the current g

相关标签:
22条回答
  • 2020-11-22 10:48

    Here's a great article (a little bit old, but still great) on SSL handshake latency. Helped me identifying SSL as the main cause of slowness for clients who were using my app through slow Internet connections:

    http://www.semicomplete.com/blog/geekery/ssl-latency.html

    0 讨论(0)
  • 2020-11-22 10:50

    This is almost certainly going to be true given that SSL requires an extra step of encryption that simply isn't required by non-SLL HTTP.

    0 讨论(0)
  • 2020-11-22 10:51

    There isn't a single answer for this.

    Encryption will always consume more CPU. This can be offloaded to dedicated hardware in many cases, and the cost will vary by algorithm selected. 3des is more expensive than AES, for example. Some algorithms are more expensive for the encrypter than the decryptor. Some have the opposite cost.

    More expensive than the bulk crypto is handshake cost. New connections will consume much more CPU. This can be reduced with session resumption, at the cost of keeping old session secrets around until they expire. This means that small requests from a client that doesn't come back for more are the most expensive.

    For cross internet traffic you may not notice this cost in your data rate, because the bandwidth available is too low. But you will certainly notice it in CPU usage on a busy server.

    0 讨论(0)
  • 2020-11-22 10:53

    To really understand how HTTPS will increase your latency, you have to understand how HTTPS connections are established. Here is a nice diagram. The key is that instead of the client getting the data after 2 "legs" (one round trip, you send a request, the server sends a response), the client won't get data until at least 4 legs (2 round trips). So, if it takes 100 ms for a packet to move between the client and the server, your first HTTPS request will take at least 500 ms.

    Of course, this can be mitigated by re-using the HTTPS connection (which browsers should do), but it does explain part of that initial stall when loading up an HTTPS web site.

    0 讨论(0)
  • 2020-11-22 10:53

    There seems to be a nasty edge case here: Ajax over congested wifi.

    Ajax usually means that the KeepAlive has timed out after say 20 seconds. However, the wifi means that the (ideally fast) ajax connection has to make multiple round trips. Worse, the wifi often loses packets, and there are TCP retransmits. In this case, HTTPS performs really really badly!

    0 讨论(0)
  • 2020-11-22 10:53

    HTTPS has encryption/decryption overhead so it will always be slightly slower. SSL termination is very CPU intensive. If you have devices to offload SSL, the difference in latencies might be barely noticeable depending on the load your servers are under.

    0 讨论(0)
提交回复
热议问题