{"id":4465,"date":"2015-01-25T13:14:18","date_gmt":"2015-01-25T05:14:18","guid":{"rendered":"https:\/\/www.icocean.com\/blog\/?p=4465"},"modified":"2015-01-25T13:20:24","modified_gmt":"2015-01-25T05:20:24","slug":"a-simple-performance-comparison-of-https-spdy-and-http2","status":"publish","type":"post","link":"https:\/\/www.icocean.com\/blog\/?p=4465","title":{"rendered":"A Simple Performance Comparison of HTTPS, SPDY and HTTP\/2"},"content":{"rendered":"<p>Firefox 35 was released this week and became the first browser to enable support for the <a title=\"HTTP\/2 specification\" href=\"https:\/\/http2.github.io\/http2-spec\/\">HTTP\/2 protocol<\/a> by default.<\/p>\n<p>The HTTP\/2 specification has not been finalised so Firefox actually enabled the <a title=\"HTTP\/2 Draft 14\" href=\"https:\/\/tools.ietf.org\/html\/draft-ietf-httpbis-http2-14\">Draft 14 version of HTTP\/2<\/a> but little is expected to change in the final draft. Google is now supporting HTTP\/2 draft 14 on its web servers alongside the <a title=\"SPDY Protocol\" href=\"http:\/\/en.wikipedia.org\/wiki\/SPDY\">SPDY protocol<\/a> giving us a chance to compare the performance of raw HTTPS, SPDY and HTTP\/2 on the same web page.<\/p>\n<p>We also <a title=\"Download HttpWatch\" href=\"http:\/\/www.httpwatch.com\/download\/\">updated HttpWatch <\/a>this week so that it supports HTTP\/2 within Firefox. It has new columns to display information about the protocols being used by each request:<\/p>\n<p><a href=\"https:\/\/www.icocean.com\/blog\/wp-content\/uploads\/auto_save_image\/2015\/01\/051418Qc7.png\"><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-2145 size-full alignnone\" src=\"https:\/\/www.icocean.com\/blog\/wp-content\/uploads\/auto_save_image\/2015\/01\/051418Qc7.png\" alt=\"New HTTP\/2 Columns\" width=\"603\" height=\"187\" \/><\/a><\/p>\n<h2>The Performance Comparison<\/h2>\n<p>The performance test used HttpWatch with Firefox to run a series of simple page load tests against the <a title=\"Google UK\" href=\"https:\/\/www.google.co.uk\/\">Google UK home page<\/a> using the three protocols:<\/p>\n<ul>\n<li>Raw HTTPS<\/li>\n<li>SPDY\/3.1<\/li>\n<li>HTTP\/2<\/li>\n<\/ul>\n<p>We switched between the protocols by enabling and disabling the following entries in Firefox\u2019s about:config page:<\/p>\n<p><a href=\"https:\/\/www.icocean.com\/blog\/wp-content\/uploads\/auto_save_image\/2015\/01\/051418CbY.png\"><img loading=\"lazy\" decoding=\"async\" class=\" size-full wp-image-2149 alignnone\" src=\"https:\/\/www.icocean.com\/blog\/wp-content\/uploads\/auto_save_image\/2015\/01\/051418CbY.png\" alt=\"Controlling FIrefox Protocol Support\" width=\"464\" height=\"322\" \/><\/a><\/p>\n<p>Each test was performed in a fresh instance of Firefox with an empty browser cache. Although this testing was simplistic and only used a simple page it does highlight some important differences between the protocols.<br \/>\n<!--more--><\/p>\n<h3>Test #1 \u2013 Size of Request and Response Headers<\/h3>\n<p>Most sites already use compression when downloading textual content as it provides a significant performance benefit. Unfortunately, HTTP\/1.1 doesn\u2019t support the compression of HTTP headers that are attached to every HTTP request and response. SPDY and subsequently HTTP\/2 were designed to address this shortcoming using different types of compression.<\/p>\n<p>SPDY uses the general purpose <a href=\"http:\/\/en.wikipedia.org\/wiki\/DEFLATE\">DEFLATE <\/a>algorithm whereas HTTP\/2 uses <a title=\"HPACK Algorithm\" href=\"http:\/\/http2.github.io\/http2-spec\/compression.html\">HPACK<\/a> that was specifically designed to compress headers. It uses predefined tokens, dynamic tables and Huffman compression.<\/p>\n<p>It\u2019s possible to see the difference in the generated header sizes by looking at a request that has no content. On the Google UK home page there is beacon request that returns no content (a 204 response). These screen shots from HttpWatch show the size of the request headers in the \u2018Sent\u2019 column and the size of the response headers in the \u2018Received\u2019 column:<\/p>\n<p><a href=\"https:\/\/www.icocean.com\/blog\/wp-content\/uploads\/auto_save_image\/2015\/01\/051418gSK.png\"><img loading=\"lazy\" decoding=\"async\" class=\" size-full wp-image-2158 alignnone\" src=\"https:\/\/www.icocean.com\/blog\/wp-content\/uploads\/auto_save_image\/2015\/01\/051418gSK.png\" alt=\"HTTPS header sizes\" width=\"603\" height=\"60\" \/><\/a><a href=\"https:\/\/www.icocean.com\/blog\/wp-content\/uploads\/auto_save_image\/2015\/01\/051419s9n.png\"><img loading=\"lazy\" decoding=\"async\" class=\" size-full wp-image-2157 alignnone\" src=\"https:\/\/www.icocean.com\/blog\/wp-content\/uploads\/auto_save_image\/2015\/01\/051419s9n.png\" alt=\"SPDY header sizes\" width=\"603\" height=\"60\" \/><\/a><\/p>\n<p><a href=\"https:\/\/www.icocean.com\/blog\/wp-content\/uploads\/auto_save_image\/2015\/01\/051420CCF.png\"><img loading=\"lazy\" decoding=\"async\" class=\" size-full wp-image-2156 alignnone\" src=\"https:\/\/www.icocean.com\/blog\/wp-content\/uploads\/auto_save_image\/2015\/01\/051420CCF.png\" alt=\"HTTP\/2 header sizes\" width=\"603\" height=\"60\" \/><\/a><\/p>\n<p><em><strong>WINNER: HTTP\/2<\/strong><\/em><\/p>\n<p><strong><em>HTTP\/2 has significantly smaller header sizes due to its use of the HPACK algorithm.<\/em><\/strong><\/p>\n<h3>Test #2: Size of Response Message<\/h3>\n<p>The response message from the server is made up of the response headers and the encoded response content. Given the fact that HTTP\/2 creates the smallest headers shouldn\u2019t it always have the smallest response message?<\/p>\n<p>In HttpWatch this seems to be the case for image resources:<\/p>\n<p><a href=\"https:\/\/www.icocean.com\/blog\/wp-content\/uploads\/auto_save_image\/2015\/01\/051420Zdw.png\"><img loading=\"lazy\" decoding=\"async\" class=\" size-full wp-image-2163 alignnone\" src=\"https:\/\/www.icocean.com\/blog\/wp-content\/uploads\/auto_save_image\/2015\/01\/051420Zdw.png\" alt=\"HTTPS Image Response Size\" width=\"603\" height=\"60\" \/><\/a> <a href=\"https:\/\/www.icocean.com\/blog\/wp-content\/uploads\/auto_save_image\/2015\/01\/0514208uw.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2164\" src=\"https:\/\/www.icocean.com\/blog\/wp-content\/uploads\/auto_save_image\/2015\/01\/0514208uw.png\" alt=\"SPDY Image Response Size\" width=\"603\" height=\"60\" \/><\/a><a href=\"https:\/\/www.icocean.com\/blog\/wp-content\/uploads\/auto_save_image\/2015\/01\/051420SN1.png\"><img loading=\"lazy\" decoding=\"async\" class=\" size-full wp-image-2162 alignnone\" src=\"https:\/\/www.icocean.com\/blog\/wp-content\/uploads\/auto_save_image\/2015\/01\/051420SN1.png\" alt=\"HTTP\/2 Image Response Size\" width=\"603\" height=\"60\" \/><\/a><\/p>\n<p>However, for textual resources SPDY consistently has smaller response messages even though its headers would be larger than HTTP\/2:<\/p>\n<p><a href=\"https:\/\/www.icocean.com\/blog\/wp-content\/uploads\/auto_save_image\/2015\/01\/051420iCa.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2166\" src=\"https:\/\/www.icocean.com\/blog\/wp-content\/uploads\/auto_save_image\/2015\/01\/051420iCa.png\" alt=\"HTTPS Text Response Size\" width=\"603\" height=\"60\" \/><\/a> <a href=\"https:\/\/www.icocean.com\/blog\/wp-content\/uploads\/auto_save_image\/2015\/01\/051420TyQ.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2167\" src=\"https:\/\/www.icocean.com\/blog\/wp-content\/uploads\/auto_save_image\/2015\/01\/051420TyQ.png\" alt=\"SPDY Text Response Size\" width=\"603\" height=\"60\" \/><\/a> <a href=\"https:\/\/www.icocean.com\/blog\/wp-content\/uploads\/auto_save_image\/2015\/01\/051420ID5.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2168\" src=\"https:\/\/www.icocean.com\/blog\/wp-content\/uploads\/auto_save_image\/2015\/01\/051420ID5.png\" alt=\"HTTP\/2 Text Response Size\" width=\"603\" height=\"60\" \/><\/a><\/p>\n<p>The reason for this is the optional padding bytes that can be added to the <a title=\"HTTP\/2 DATA frame\" href=\"https:\/\/http2.github.io\/http2-spec\/#DATA\">HTTP\/2 DATA frame<\/a>. HttpWatch doesn\u2019t currently show the padding but in our debug logs we can see that the Google servers add padding to the data frames of textual resources. The <a title=\"Use of Padding in HTTP\/2\" href=\"https:\/\/http2.github.io\/http2-spec\/#padding\">reason given in the HTTP\/2 spec<\/a> for using padding is:<\/p>\n<blockquote><p>Padding can be used to obscure the exact size of frame content, and is provided to mitigate specific attacks within HTTP. For example, attacks where compressed content includes both attacker-controlled plaintext and secret data (see for example, [<a href=\"https:\/\/http2.github.io\/http2-spec\/#BREACH\">BREACH<\/a>]).<\/p><\/blockquote>\n<p>Padding isn\u2019t used for image resources because they already have a compressed format that will not contain attacker controlled plain text.<\/p>\n<p><em><strong>WINNER: SPDY<\/strong><\/em><\/p>\n<p><strong><em>The larger response bodies seen on the Google servers are due to the use of padding in data frames. Although, HTTP\/2 produces larger responses than SPDY its encrypted connections could potentially be more secure. This may be an area where tuning can be performed in a trade off between security and performance.<\/em><\/strong><\/p>\n<h3>Test #3 : Number of TCP Connects and SSL Handshakes Required During Page Load<\/h3>\n<p>Browsers achieved a performance boost in HTTP\/1.1 by increasing the maximum number of connections per host name from two to six or more. This allowed greater concurrency during the download of a page at the cost of extra TCP connections and SSL handshakes . Increasing concurrency allows the bandwidth of the network to be used more effectively because it reduces <a title=\"Blocking of requests\" href=\"http:\/\/blog.httpwatch.com\/2008\/03\/31\/blocked-time-and-ie-8\/\">the blocking of requests<\/a>.<\/p>\n<p>SPDY and HTTP\/2 support concurrency on a single TCP and SSL connection by using multiplexing to allow more than one request at a time to send and receive data on a single connection.<\/p>\n<p>By adding the \u2018Connect\u2019 and \u2018SSL Handshake\u2019 timings as a columns in HttpWatch you can see that SPDY:<\/p>\n<p><a href=\"https:\/\/www.icocean.com\/blog\/wp-content\/uploads\/auto_save_image\/2015\/01\/051420FMo.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2171\" src=\"https:\/\/www.icocean.com\/blog\/wp-content\/uploads\/auto_save_image\/2015\/01\/051420FMo.png\" alt=\"SPDY Connections\" width=\"603\" height=\"379\" \/><\/a><\/p>\n<p>And HTTP\/2:<\/p>\n<p><a href=\"https:\/\/www.icocean.com\/blog\/wp-content\/uploads\/auto_save_image\/2015\/01\/051420c1B.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2173\" src=\"https:\/\/www.icocean.com\/blog\/wp-content\/uploads\/auto_save_image\/2015\/01\/051420c1B.png\" alt=\"HTTP\/2 Connections\" width=\"603\" height=\"379\" \/><\/a><\/p>\n<p>Only create connections for different host names. Whereas, raw HTTPS may create more than one connection per host name to improve concurrency:<\/p>\n<p><a href=\"https:\/\/www.icocean.com\/blog\/wp-content\/uploads\/auto_save_image\/2015\/01\/05142090P.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2172\" src=\"https:\/\/www.icocean.com\/blog\/wp-content\/uploads\/auto_save_image\/2015\/01\/05142090P.png\" alt=\"HTTPS Connections\" width=\"603\" height=\"384\" \/><\/a><\/p>\n<p><em><strong>EQUAL WINNERS: SPDY &amp; HTTP\/2<\/strong><\/em><\/p>\n<p><strong><em>The multiplexing support added in SPDY and HTTP\/2 reduces the number of connections that have to be setup to download a page. As a side benefit web servers will not have to maintain as many active TCP connections when HTTP\/2 usage becomes more widespread.<\/em><\/strong><\/p>\n<h3>Test #4: Page Load Time<\/h3>\n<p>The \u2018Page Load\u2019 event in HttpWatch shows when the page was fully downloaded and available for use. In most cases this a reasonable measure of the speed of the page as seen by a visitor to a web site.<\/p>\n<p>The screeen shots below show the Page Load time for each of the three protocols:<a href=\"https:\/\/www.icocean.com\/blog\/wp-content\/uploads\/auto_save_image\/2015\/01\/051420IdJ.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2178\" src=\"https:\/\/www.icocean.com\/blog\/wp-content\/uploads\/auto_save_image\/2015\/01\/051420IdJ.png\" alt=\"HTTPS Page Load\" width=\"603\" height=\"332\" \/><\/a><\/p>\n<p><a href=\"https:\/\/www.icocean.com\/blog\/wp-content\/uploads\/auto_save_image\/2015\/01\/0514207Vo.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2176\" src=\"https:\/\/www.icocean.com\/blog\/wp-content\/uploads\/auto_save_image\/2015\/01\/0514207Vo.png\" alt=\"SPDY Page Load\" width=\"603\" height=\"332\" \/><\/a> <a href=\"https:\/\/www.icocean.com\/blog\/wp-content\/uploads\/auto_save_image\/2015\/01\/051420wR8.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2177\" src=\"https:\/\/www.icocean.com\/blog\/wp-content\/uploads\/auto_save_image\/2015\/01\/051420wR8.png\" alt=\"HTTP\/2 Page Load\" width=\"603\" height=\"332\" \/><\/a><\/p>\n<p><em><strong>WINNER HTTP\/2<\/strong><\/em><\/p>\n<p><em><strong>The Page Load timing was worse for raw HTTPS probably due to the lack of header compression and the additional TCP connections and SSL Handshakes required. For more complex pages the speed advantage of SPDY and HTTP\/2 should be even greater.<br \/>\n<\/strong><\/em><\/p>\n<p><em><strong>We also found that HTTP\/2 was consistently faster than SPDY even though its response messages were often larger. The advantage was probably due to the smaller GET request messages produced by HPACK compression. Our network connection to the internet, like many others, is asymmetric in nature \u2013 the network upload speed is less than the download speed. This means that any saving in <a href=\"http:\/\/blog.httpwatch.com\/2008\/01\/18\/the-performance-impact-of-uploaded-data\/\">uploaded data has much more impact<\/a> than the equivalent saving in downloaded data.<\/strong><\/em><\/p>\n<h2>Conclusion<\/h2>\n<p>HTTP\/2 is likely to provide significant performance advantages compared to raw HTTPS and even SPDY. However the use of padding in response messages is an area of potential concern where there could be a trade-off between performance and security.<\/p>\n<p>Source:\u00a0http:\/\/blog.httpwatch.com\/2015\/01\/16\/a-simple-performance-comparison-of-https-spdy-and-http2\/<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Firefox 35 was released this week and became the first  <a href='https:\/\/www.icocean.com\/blog\/?p=4465' class='excerpt-more'>[&#8230;]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[4071,3964,1756,3704,3742,1881,1706],"class_list":["post-4465","post","type-post","status-publish","format-standard","hentry","category-4","tag-http","tag-http2-0","tag-https","tag-performance","tag-spdy","tag-1881","tag-1706","category-4-id","post-seq-1","post-parity-odd","meta-position-corners","fix"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4465","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4465"}],"version-history":[{"count":3,"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4465\/revisions"}],"predecessor-version":[{"id":4493,"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4465\/revisions\/4493"}],"wp:attachment":[{"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4465"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4465"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4465"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}