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

HTTP/2 を読み解く技術

Moto Ishizawa
January 27, 2014

HTTP/2 を読み解く技術

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

Moto Ishizawa

January 27, 2014

More Decks by Moto Ishizawa

Other Decks in Technology


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

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

    #3 Data #4 Data #5 ૹ৴ʹࣦഊ͠ ࠶ૹ͕ඞཁͳσʔλ ૹ৴଴ͪͷσʔλͨͪ )P-#MPDLJOH 6/27
  3. Flow control is used for both individual streams and for

    the connection as a whole. “ ” ― 5.2. Flow Control 8/27
  4. Flow control Client 53όΠτड৴ͨ͠ͷͰ ࢒Γ͸47όΠτ 53όΠτૹ৴ 47όΠτૹ৴ 47όΠτड৴ͨ͠ͷͰ ࢒Γ͸0όΠτ ΢Πϯυ΢͕100όΠτ

    Ͱ͋Δ͜ͱΛ௨஌ Server ߹ܭͰ100όΠτૹ৴ ͨ͠ͷͰҰ࣌ૹ৴ఀࢭ 89όΠτॲཧͨ͠ͷͰ 89όΠτ·Ͱ͸ૹ৴ Մೳͳ͜ͱΛ఻͑Δ ૹ৴Λ࠶։ 89όΠτૹ৴ 10/27
  5. 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
  6. 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
  7. 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
  8. 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
  9. 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
  10. The 1xx series of HTTP response status codes are not

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

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

    Expect: 100-continue ৘ใఏڙϨεϙϯε ϦΫΤετϘσΟ Ϩεϙϯε The 1xx Series of HTTP response status codes 22/27
  13. 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
  14. 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
  15. 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