HTTP/2 を読み解く技術

20e958629852b653fad35c99706fc3ac?s=47 Moto Ishizawa
January 27, 2014

HTTP/2 を読み解く技術

HTTP2.0 勉強会 #3での発表資料。

20e958629852b653fad35c99706fc3ac?s=128

Moto Ishizawa

January 27, 2014
Tweet

Transcript

  1. )551ΛಡΈղٕ͘ज़

  2. Moto Ishizawa (@summerwind) 1/27

  3. http://summerwind.jp/docs/draft-ietf-httpbis-http2-09/ 2/27

  4. )551ͷ࢓༷ॻΛಡΈղͨ͘Ίʹඞ ཁͳ஌ࣝ΍ٕज़Λ঺հ͠·͢ɻ 3/27

  5. ωοτϫʔΫؔ࿈

  6. HTTP/1.1 pipelining only partially addressed request concurrency and suffers from

    head-of-line blocking. “ ” ― 1. Introduction 5/27
  7. Head-of-line Blocking (HoL Blocking) σʔλΛૹ৴͢ΔΩϡʔ Data #1 Data #2 Data

    #3 Data #4 Data #5 ૹ৴ʹࣦഊ͠ ࠶ૹ͕ඞཁͳσʔλ ૹ৴଴ͪͷσʔλͨͪ )P-#MPDLJOH 6/27
  8. Head-of-line Blocking (HoL Blocking) Client Server HTTP/1.1 pipelining ΋͠࠷ॳͷϨεϙϯεͷॲཧʹ ͕͔͔࣌ؒͬͨ৔߹ɺ2ͭ໨Ҏ߱ͷ

    Ϩεϙϯε΋ͦΕʹҾ͖ͣΒΕΔ (HoL Blocking) ϦΫΤετͷૹ৴ Ϩεϙϯεͷૹ৴ 7/27
  9. Flow control is used for both individual streams and for

    the connection as a whole. “ ” ― 5.2. Flow Control 8/27
  10. Flow control 9/27 σʔλͷ௨৴࣌ʹɺड৴ଆͷॲཧ͕௥͍͔ͭͣʹσʔλͷ औΓ͜΅͕͠ൃੜ͢ΔͷΛ๷͙ͨΊɺঢ়گʹԠͯ͡ૹ৴ଆ ͕σʔλͷૹ৴Λఀࢭͨ͠Γɺૹ৴ྔΛௐ੔ͨ͠Γ͢Δͨ Ίͷ࢓૊Έɻ ! ௨৴ͷ։࢝࣌ʹड৴ଆ͕΢Πϯυ΢αΠζͱݺ͹ΕΔҰ౓ ʹड৴Մೳͳ༰ྔΛૹ৴ଆʹ௨஌͠ɺૹ৴ଆ͸ͦͷαΠζ

    ʹैͬͯૹ৴ྔΛ੍ޚ (΢Πϯυ΢੍ޚ) ͢Δɻ
  11. Flow control Client 53όΠτड৴ͨ͠ͷͰ ࢒Γ͸47όΠτ 53όΠτૹ৴ 47όΠτૹ৴ 47όΠτड৴ͨ͠ͷͰ ࢒Γ͸0όΠτ ΢Πϯυ΢͕100όΠτ

    Ͱ͋Δ͜ͱΛ௨஌ Server ߹ܭͰ100όΠτૹ৴ ͨ͠ͷͰҰ࣌ૹ৴ఀࢭ 89όΠτॲཧͨ͠ͷͰ 89όΠτ·Ͱ͸ૹ৴ Մೳͳ͜ͱΛ఻͑Δ ૹ৴Λ࠶։ 89όΠτૹ৴ 10/27
  12. Flow control (HTTP/2) Client ίωΫγϣϯͷ΢Πϯυ΢͸࢒Γ65,482όΠτ ετϦʔϜID: 1ͷ΢Πϯυ΢͸࢒Γ47όΠτ ετϦʔϜID: 1ʹ53όΠτૹ৴ ετϦʔϜID:

    1ʹ47όΠτૹ৴ ίωΫγϣϯͷ΢Πϯυ΢͸࢒Γ65,435όΠτ ετϦʔϜID: 1ͷ΢Πϯυ΢͸࢒Γ0όΠτ SETTINGSϑϨʔϜͷ SETTINGS_INITIAL_WINDOW_SIZEͰετϦʔϜ ͷ΢Πϯυ΢͕100όΠτͰ͋Δ͜ͱΛ௨஌ (ίωΫγϣϯͷ΢Πϯυ΢͸65,535όΠτݻఆ) Server 89όΠτΛॲཧͨ͠ͷͰɺετϦʔϜID: 1ʹ WINDOW_UPDATEϑϨʔϜΛૹ৴ͯ͠ɺ ετϦʔϜID: 1ͷ΢Πϯυ΢Λ89όΠτʹ͢Δ ετϦʔϜID: 1ʹ89όΠτૹ৴ 11/27
  13. Note, however, that this can lead to suboptimal use of

    available network resources if flow control is enabled without knowledge of the bandwidth-delay product. “ ” ― 5.2.2. Appropriate Use of Flow Control 12/27
  14. Bandwidth-delay product (BDP) ωοτϫʔΫଳҬ෯ × σʔλͷԟ෮஗Ԇ࣌ؒ ωοτϫʔΫ্ʹྲྀ͢͜ͱ͕Ͱ͖Δ࠷దͳσʔλͷྔΛࣔ͢ɻ ΢Πϯυ΢αΠζͷ࠷ద஋ΛٻΊΔͨΊʹ࢖༻͢Δ஋ɻ 13/27

  15. Bandwidth-delay product (BDP) ྫ: RTT͕100ms͔͔Δ10MbpsͷճઢͷBDPΛܭࢉ͢Δɻ 10Mbps = 10,000,000bit/s = 1,221KB/s

    100ms = 0.1s 1,221KB/s × 0.1s = 122.1KB ͜ͷ஋͔Βɺ΢Πϯυ΢αΠζ͸࠷௿Ͱ΋122.1KB͕ඞཁɻ BDPͷ஋Λ΋ͱʹ΢Πϯυ΢αΠζͷνϡʔχϯάΛ͓͜ͳ͏ɻ 14/27
  16. 5-4ؔ࿈

  17. A client that makes a request to an "https" URI

    without prior knowledge about support for HTTP/2.0 uses TLS with the application layer protocol negotiation extension. “ ” ― 3.3. Starting HTTP/2.0 for "https" URIs 16/27
  18. Application Layer Protocol Negotiation (ALPN) Client Server TLS Handshake ClientHello

    ServerHello ALPN Extension HTTP/1 HTTP/2 SPDY/3 ALPN Extension Selected protocol HTTP/2 17/27
  19. Application Layer Protocol Negotiation (ALPN) https://github.com/http2/http2-spec/wiki/ALPN-Status 18/27

  20. )551Yؔ࿈

  21. The 1xx series of HTTP response status codes are not

    supported in HTTP/2.0. “ ” ― 8.1.1. Informational Responses 20/27
  22. The 1xx Series of HTTP response status codes 100 Continue

    ϦΫΤετϔομΛड৴ͨ͠αʔόʔ͕ɺϦΫΤετϘςΟͷ ड৴͕Մೳͳ͜ͱΛ஌ΒͤΔͨΊͷεςʔλείʔυɻ ! 101 Switching Protocols ௨৴ʹ࢖༻͢ΔϓϩτίϧΛ HTTP ͔Βଞͷϓϩτίϧʹ ੾Γସ͑ΔͨΊʹ࢖༻͢Δεςʔλείʔυɻ 21/27
  23. Client Server 100 Continue ϦΫΤετ 100 Continue POST /search HTTP/1.1

    Expect: 100-continue ৘ใఏڙϨεϙϯε ϦΫΤετϘσΟ Ϩεϙϯε The 1xx Series of HTTP response status codes 22/27
  24. In HTTP/2.0, the CONNECT method is used to establish a

    tunnel over a single HTTP/2.0 stream to a remote host. “ ” ― 8.3. The CONNECT Method 23/27
  25. CONNECT (HTTP/1.1) Client Proxy Server ϦΫΤετ CONNECT example.com:80 HTTP/1.1 Host:

    example.com:80 Ϩεϙϯε 200 Connection Established αʔόʔʹର͢ΔϦΫΤετ GET /index.html HTTP/1.1 தܧ͞ΕͨϦΫΤετ GET /index.html HTTP/1.1 ઀ଓ 24/27
  26. CONNECT (HTTP/2) Client Proxy Server HEADERS ϑϨʔϜ :method : CONNECT

    :authority : example.com:80 HEADERS ϑϨʔϜ :status : 200 DATA ϑϨʔϜ GET /index.html HTTP/1.1 ϦΫΤετ GET /index.html HTTP/1.1 ઀ଓ 25/27
  27. http://bit.ly/browser-networking 26/27

  28. Enjoy HTTP/2 ;-)