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

HTTP/2 : One connection to rule them all

HTTP/2 : One connection to rule them all

Jérémy Courtial

December 11, 2014
Tweet

More Decks by Jérémy Courtial

Other Decks in Technology

Transcript

  1. The time from the source sending a packet to the

    destination receiving it Latency Maximum throughput of a logical or physical communication path Bandwidth
  2. Impact of bandwidth Page Load Time (ms) 1 000 1

    440 1 880 2 320 2 760 3 200 Bandwidth 1 Mbps 3 Mbps 5 Mbps 7 Mbps 9 Mbps
  3. Impact of latency Page Load Time (ms) 500 1 200

    1 900 2 600 3 300 4 000 RTT 240ms 200ms 160ms 120ms 80ms 40ms 0ms
  4. $> telnet cern.ch 80 GET /hello <html> <body> Hello Tim!

    </body> </html> Connected to 188.184.9.234 Connection closed
  5. So many more RTT DNS lookup 1 RTT TCP handshake

    1 RTT TLS handshake 1-2 RTTs HTTP request 1-n RTTs
  6. GET index.html GET script.js GET styles.css GET cat.jpg Pipelining ?

    Head of line blocking index.html script.js cat.jpg styles.css
  7. Multiple connections 4-8 per hosts GET script.js GET picture.jpg GET

    theme.css GET img3.jpg GET main.css GET img2.jpg GET angular.js GET print.css GET index.html GET img1.jpg GET boot.css GET utils.js GET intro.mp4 GET bg.png GET jquery.js GET icon.png
  8. Optimizations… • Sharding • Concatenation • Spriting • Inlining (network

    overhead) (break cache) (break cache) (break cache, duplication)
  9. Based on SPDYv2 Retains semantic compatibility with HTTP 1.x Addresses

    « head of line blocking » & multiple connections issues Improves overall performances
  10. :authority: domain.org :method: POST :path: /hello :scheme: https content-type: application/json

    content-length:12 {"greeting":"Hello world"} HEADERS frame DATA frame
  11. Binary format Length (24) Type (8) Flags (8) Stream identifier

    (31) R Frame payload (n) 0 1 2 4 5 16 Ko < max size < 16 Mo
  12. HEADERS frame DATA frame DATA frame HEADERS frame DATA frame

    Request message Response message Stream
  13. DATA frame DATA frame HEADERS frame DATA frame HEADERS frame

    Request message Response message Stream
  14. DATA frame DATA frame HEADERS frame DATA frame HEADERS frame

    DATA frame DATA frame HEADERS frame DATA frame HEADERS frame Stream 2 Stream 1 DATA frame DATA frame HEADERS frame DATA frame HEADERS frame Stream 3
  15. HTTP 2.0 connection stream 3 HEADERS stream 7 DATA stream

    7 HEADERS stream 5 DATA stream 1 DATA stream 1 DATA stream 1 DATA
  16. Now more like that index.html main.css main.js jquery.js bootstrap.css bootstrap.js

    intro.mp4 bg.png img1.jpg img1.jpg img1.jpg img1.jpg img1.jpg
  17. Headers compression method GET scheme https host domain.org path /hello

    user-agent Mozilla/5.0 Request 1 method GET scheme https host domain.org path /goodbye user-agent Mozilla/5.0 Request 2 :method GET :scheme https :host domain.org :path /hello user-agent Mozilla/5.0 HEADERS frame (stream 1)
  18. Headers compression method GET scheme https host domain.org path /hello

    user-agent Mozilla/5.0 Request 1 method GET scheme https host domain.org path /goodbye user-agent Mozilla/5.0 Request 2 :method GET :scheme https :host domain.org :path /hello user-agent Mozilla/5.0 HEADERS frame (stream 1) :path /goodbye HEADERS frame (stream 3)
  19. Upgrade & Discovery Through TLS & ALPN Because you do

    TLS, right ? With prior knowledge You just know Upgrade header
  20. Upgrade header strategy GET /hello HTTP/1.1 Host: domain.org Connection: Upgrade,

    HTTP2-Settings Upgrade: HTTP/2.0 HTTP2-Settings: (SETTINGS payload) HTTP/1.1 200 OK HTTP/1.1 101 Switching Protocols
  21. GET /hello HTTP/1.1 HTTP/1.1 200 OK Content-length: 112 Content-type: text/html

    (HTTP 1.1 response) HTTP/1.1 101 Switching Protocols Upgrade header strategy
  22. GET /hello HTTP/1.1 HTTP/1.1 200 OK HTTP/1.1 101 Switching Protocols

    Connection: Upgrade Upgrade: HTTP/2.0 (HTTP 2.0 response) Upgrade header strategy
  23. Roadmap Are we there yet ? 2014 June Draft 13

    - Last Call Draft 10 Draft 11 Draft 12 Draft 14 Draft 15 Draft 16 Dec Submit for standardization
  24. GET /big_file TCP data TCP data TCP data TCP RST

    Closed TCP SYN TCP SYN/ACK HTTP 1.x Close the TCP connection to cancel the request
  25. HTTP 2.0 Close the stream, keep the connection stream 1

    HEADERS stream 1 DATA stream 1 DATA stream 1 DATA stream 1 RST stream 3 HEADERS stream 3 DATA
  26. Bibliography Ilya Grigorik (@igrigorik) High Performance Browser Networking book https://www.igvita.com/

    Mark Nottingham (@mnot) https://www.mnot.net/ It's the Latency, Stupid http://goo.gl/g26hOo More Bandwidth Doesn't Matter (much) http://goo.gl/wuvD1R , Stuart Cheshire , Mike Belshe