http和https在性能上有什么主要的区别吗?我似乎记得读到过HTTPS的速度是HTTP的五分之一。这对当前的web服务器/浏览器有效吗?如果有,是否有相关白皮书支持?


当前回答

因为我正在为我的项目调查同样的问题,我发现了这些幻灯片。年长但有趣:

http://www.cs.nyu.edu/artg/research/comparison/comparison_slides/sld001.htm

其他回答

HTTPS requires an initial handshake which can be very slow. The actual amount of data transferred as part of the handshake isn't huge (under 5 kB typically), but for very small requests, this can be quite a bit of overhead. However, once the handshake is done, a very fast form of symmetric encryption is used, so the overhead there is minimal. Bottom line: making lots of short requests over HTTPS will be quite a bit slower than HTTP, but if you transfer a lot of data in a single request, the difference will be insignificant.

然而,keepalive是HTTP/1.1的默认行为,所以你会在同一个连接上进行一次握手,然后进行多次请求。这对HTTPS产生了重大影响。您可能应该对站点进行概要分析(正如其他人建议的那样)以确保这一点,但我怀疑性能差异不会很明显。

Browsers can accept HTTP/1.1 protocol with either HTTP or HTTPS, yet browsers can only handle HTTP/2.0 protocol with HTTPS. The protocol differences from HTTP/1.1 to HTTP/2.0 make HTTP/2.0, on average, 4-5 times faster than HTTP/1.1. Also, of sites that implement HTTPS, most do so over the HTTP/2.0 protocol. Therefore, HTTPS is almost always going to be faster than HTTP simply due to the different protocol it generally uses. However, if HTTP over HTTP/1.1 is compared with HTTPS over HTTP/1.1, then HTTP is slightly faster, on average, than HTTPS.

以下是我使用Chrome(版本64)运行的一些比较:

HTTPS over HTTP/1.1:

0.47秒的平均页面加载时间 在HTTP/1.1上比HTTP慢0.05秒 比HTTP/2.0上的HTTPS慢0.37秒

HTTP over HTTP/1.1

0.42秒的平均页面加载时间 比HTTP/1.1上的HTTPS快0.05秒 比HTTP/2.0上的HTTPS慢0.32秒

HTTPS over HTTP/2.0

平均加载时间0.10秒 在HTTP/1.1上比HTTP快0.32秒 比HTTPS/1.1快0.37秒

因为我正在为我的项目调查同样的问题,我发现了这些幻灯片。年长但有趣:

http://www.cs.nyu.edu/artg/research/comparison/comparison_slides/sld001.htm

2014年12月更新

您可以使用AnthumChris的HTTP vs HTTPS测试网站在自己的浏览器中轻松测试HTTP和HTTPS性能之间的差异:“此页面测量其在不安全的HTTP和加密的HTTPS连接上的加载时间。这两个页面都加载了360张独特的非缓存图像(总计2.04 MB)。”

结果可能会让你大吃一惊。

拥有最新的HTTPS性能知识是很重要的,因为让我们加密证书权威机构将在2015年夏天开始发布免费、自动化和开放的SSL证书,这要感谢Mozilla、Akamai、Cisco、电子前沿基金会和IdenTrust。

2015年6月更新

Let 's Encrypt更新-到2015年9月:

Let’s Encrypt Launch Schedule(2015年6月16日) 让我们加密根证书和中间证书(2015年6月4日) Let's Encrypt订阅协议草案(2015年5月21日)

更多推特信息:@letsencrypt

有关HTTPS和SSL/TLS性能的更多信息,请参阅:

TLS快吗? 高性能浏览器网络,第4章:传输层安全 超频SSL SSL处理的解剖和性能

有关使用HTTPS的重要性的更多信息,请参阅:

为什么什么都用HTTPS ?(仅https标准) Let 's Encrypt(互联网安全研究组) HTTPS无处不在(电子前沿基金会)

总而言之,让我引用Ilya Grigorik的话:“TLS只有一个性能问题:它的应用不够广泛。其他一切都可以优化。”

感谢Chris (HTTP vs HTTPS测试基准的作者)在下面给出的评论。

这里有一篇关于SSL握手延迟的很棒的文章(有点老,但仍然很棒)。帮助我确定SSL是客户端通过较慢的互联网连接使用我的应用程序的缓慢的主要原因:

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