Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Why HTTP/2

Nacho Coloma
September 21, 2015

Why HTTP/2

HTTP/2 is now supported by 60% of the current browser market share. We should start questioning our best practices and understand a protocol that is designed to reduce our Page Load Time by 50%.

Nacho Coloma

September 21, 2015
Tweet

More Decks by Nacho Coloma

Other Decks in Technology

Transcript

  1. About me · +15 years doing this software thing ·

    Organizer at Codemotion Madrid · Google Developer Expert for Cloud Platform
  2. But I’m also a nerd I like to code, and

    I speak about the things I like. HTTP/2 is something that we don’t speak too much about. Like, of 330 entries in Codemotion Madrid, only one is about this.
  3. Supported by Chrome, Firefox, Internet Explorer 11 for Windows 10,

    Microsoft Edge, Opera, Safari 9 (60% of the browser market share) http://caniuse.com/#feat=http2
  4. New features introduced with HTTP/2 0 0 METHODS STATUS CODES

    HEADERS https://http2.github.io/http2-spec/
  5. New features introduced with HTTP/2 0 0 METHODS STATUS CODES

    HEADERS 1 https://http2.github.io/http2-spec/
  6. New features introduced with HTTP/2 0 0 METHODS STATUS CODES

    HEADERS 1 https://http2.github.io/http2-spec/
  7. Key differences to HTTP/1.x · Binary, instead of textual ·

    Fully multiplexed, instead of ordered and blocking · Can use one connection for parallelism · Uses header compression to reduce overhead · Allows servers to “push” responses proactively into client caches
  8. Binary, instead of textual Cannot do HTTP/2 using telnet Not

    really a problem: curl, Chrome devtools, Wireshark. Not backwards-compatible: requires HTTPS to avoid breaking any intermediate proxies.
  9. Does HTTP/2 require encryption? · As a standard, no. ·

    But currently no browser supports HTTP/2 unencrypted. · As a binary protocol, this is important for backwards compatibility. · Also, it’s the right thing to do. · Only full, end-to-end encryption! · Using e.g. CloudFlare intermediate proxy with HTTP 1.1 behind will not work.
  10. Research done at Google shows that an increase from 5Mbps

    to 10Mbps results in a disappointing 5% improvement in page load times. Ilya Grigorik, Google https://www.igvita.com/2011/10/20/faster-web-vs-tcp-slow-start/
  11. Upgrade your kernel now! Initial congestion window (cwnd) increased from

    3-4 to 10 packets (2- 3x) Switch from Multiplicative Decrease and Additive Increase (AIMD) to Proportional Rate Reduction (PRR) for an extra 3-10% reduction in latency.
  12. One connection HTTP 1.1: Between 4 and 8 connections even

    more with multiple DNS names HTTP/2: One connection
  13. Compress HTTP headers With HTTP 1.1, headers are always sent

    in plain text also with gzipped responses With HTTP/2, headers headers are compressed using HPACK SPDY was using gzip, but there were security implications (CRIME)
  14. Key differences to HTTP/1.x · Binary, instead of textual ·

    Fully multiplexed, instead of ordered and blocking · Allows servers to “push” responses proactively into client caches · Can use one connection for parallelism · Uses header compression to reduce overhead
  15. Is this the same thing as SPDY? · SPDY was

    an experimental protocol developed at Google in 2009 · Target: a 50% reduction in page load time by reducing latency · Gather real performance data to (in)validate the experimental protocol · It was the starting point for the HTTP/2 standard, and is now deprecated
  16. Server and library support Most servers are already on board

    Apache (mod_h2), NGINX alpha, Netty, Jetty, IIS 10 Others are getting there Squid Cool client libraries like OkHttp or gRPC Though probably they can only benefit from header compression
  17. It’s time to reconsider our best practices Sharding using different

    DNS names Concatenation of resources (and cache invalidation) data: URIs inlining CSS assets Sprites Delayed image loading Inlined resources in HTML But remember: only 60% of browser market share! bit.ly/http2-opt
  18. Time for some Q & A Nacho Coloma — CTO

    at Extrema Sistemas Google Developer Expert @nachocoloma BTW Codemotion is awesome. You should come. Just saying.