Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Very beginning of HTTP2
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Akira Morikawa
July 06, 2018
Technology
160
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Very beginning of HTTP2
HTTP/2 仕様を調べてまとめてみた
Akira Morikawa
July 06, 2018
More Decks by Akira Morikawa
See All by Akira Morikawa
コロナ禍だからこそ考えるオフラインコミュニティの意義 / significance of community
ariaki
0
2.2k
アウトプットの始め方/start output 20230121
ariaki
0
360
web-secure-phpcon2020
ariaki
3
3.7k
オブジェクトライフサイクルとメモリ管理を学ぼう / OOC 2020
ariaki
8
4.1k
エンジニアはアウトプットによって成長できるのか? / Grow with your output
ariaki
24
6.7k
アウトプットを始めよう / How to begin output jawsug-bgnr
ariaki
2
4k
参加者の安全を守れていますか? / Protecting community safety
ariaki
1
7.6k
タピオカに学ぶ二段階認証 / tapioca-mfa
ariaki
5
1.4k
古に学ぶ個人開発のススメ / My recommendation of personal development
ariaki
1
1.6k
Other Decks in Technology
See All in Technology
LLMと共に進化するプロセスを目指して
ymatsuwitter
12
3.6k
10倍の生産性を実現するAI駆動並列エージェントのすべて
kumaiu
4
970
AI-DLCを活用した高品質・安全なAI駆動開発実践 / AI Driven Development
yoshidashingo
1
380
Ruby::Boxでできること、Refinementsでできること
joker1007
3
400
EventBridge Connection
_kensh
5
650
AI-DLCを活用した高品質・安全なAI駆動開発実践 / AI Driven Development with AI-DLC
yoshidashingo
0
150
コードレビューを制するチームがソフトウェアデリバリーのフローを制す / Beyond Code Review: Distributing Its Responsibilities Across the SDLC
mtx2s
4
1.3k
LLMにもCAP定理があるという話
harukasakihara
0
100
OCI Oracle AI Database Services新機能アップデート(2026/03-2026/05)
oracle4engineer
PRO
0
290
Oracle AI Database@Azure:サービス概要のご紹介
oracle4engineer
PRO
6
1.9k
AI Testing Talks: Challenges of Applying AI in Software Testing: From Hype to Practical Use
exactpro
PRO
1
140
新規事業を牽引する技術選定 〜フルスタックTypeScript開発の実践事例〜
nullnull
3
370
Featured
See All Featured
Un-Boring Meetings
codingconduct
0
310
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.5k
WENDY [Excerpt]
tessaabrams
11
38k
First, design no harm
axbom
PRO
2
1.2k
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
240
Building the Perfect Custom Keyboard
takai
2
790
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
0
1.6k
Test your architecture with Archunit
thirion
1
2.3k
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
200
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.8k
Navigating Weather and Climate Data
rabernat
0
210
Site-Speed That Sticks
csswizardry
13
1.2k
Transcript
Very beginning of HTTP/2 2018-07-06 / #web_kaiwai @ariaki4dev What’s Hypertext
Transfer Protocol ?
HTTP Histories HTTP/2 Features HTTP/2 Compatibility Agenda
HTTP Histories
None
HTTP/0.9 HTTP/1.0 HTTP/1.1 HTTP/2 - 1991 年に登場 - GET メソッド
- ステータスコードなし - ヘッダなし - Content-Type が指定できないので HTML のみ転送可 HTTP Histories
HTTP/0.9 HTTP/1.0 HTTP/1.1 HTTP/2 GET /index.html Request <HTML>HELLO WORLD</HTML> Response
HTTP Histories
HTTP/0.9 HTTP/1.0 HTTP/1.1 HTTP/2 - 1996 年に登場 ( RFC1945 )
- HEAD / POST メソッドが追加された - PUT / DELETE は正式仕様ではなく参考仕様 - ステータスコードが追加された - ヘッダが追加された - HTML 以外の転送にも対応 - クッキーはまだない HTTP Histories
HTTP/1.1 HTTP/2 GET /index.html HTTP/1.0 User-Agent: NCSA_Mosaic/2.0 (Windows 3.1) Request
HTTP/0.9 HTTP/1.0 200 OK Date: Fri, 06 Jul 2018 19:00:00 GMT Server: CERN/3.0 libwww/2.17 Content-Type: text/html <HTML>HELLO WORLD</HTML> Response HTTP Histories
HTTP/0.9 HTTP/1.0 HTTP/1.1 HTTP/2 - 1999 年に登場 ( RFC2068 )
- PUT / DELETE / OPTIONS / TRACE / CONNECT メソッドが追加された - 1台の HTTPd で複数ドメインに対応した ( Host ) - コネクションの再利用に対応した ( Keep-Alive ) - Chunked レスポンスに対応した - 言語 / タイプ / エンコーディングのネゴシエーションに対応した - HTTP パイプラインに対応した - 1つの TCP 接続で複数 HTTP リクエストを応答を待たずに送信できる HTTP Histories
GET /index.html HTTP/1.1 Host: ariaki.info Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8 Accept-Encoding: gzip, deflate,
br Accept-Language: ja,en-US;q=0.9,en;q=0.8 Cache-Control: max-age=0 HTTP/2 Request HTTP/0.9 HTTP/1.0 HTTP/1.1 HTTP Histories
HTTP/1.1 200 OK Date: Fri, 06 Jul 2018 19:00:00 GMT
Server: Apache Content-Type: text/html; charset=UTF-8 Cache-Control: private, max-age=0 Expires: -1 Connection: Keep-Alive <HTML>HELLO WORLD</HTML> HTTP/2 Response HTTP/0.9 HTTP/1.0 HTTP/1.1 HTTP Histories
HTTP/0.9 HTTP/1.0 HTTP/1.1 HTTP/2 - 2015 年に登場 ( RFC7540 )
- HTTP/1.1 との後方互換性を維持 - 多くの新機能や改善 HTTP Histories 詳細は次のトピック
HTTP/2 Features
- ネゴシエーション方法として以下をサポート - h2c ( 非暗号通信 ) - Upgrade :
初回は HTTP/1.1 接続し、Upgrade ヘッダで対応を通知 - Direct : クライアントから直接 HTTP/2 接続を指定 - h2 ( 暗号通信 ) - ALPN : TLS/1.2+ 拡張を使用した暗号化接続 ( Application-Layer Protocol Negotiation ) - NPN : TLS/1.2+ 拡張を使用した暗号化接続 ( Next Protocol Negotiation ) 概要 Negotiation
h2c - Upgrade HTTP/1.1 101 Switching Protocols Connection: Upgrade Upgrade:
h2c : Response GET / HTTP/1.1 Host: ariaki.info Connection: Upgrade, HTTP2-Settings Upgrade: h2c HTTP2-Settings: <<BASE64 ENCODED BINARY>> Request Negotiation
h2c - Direct <<BASE64 ENCODED BINARY>> Response PRI * HTTP/2.0
SM Request Negotiation
h2 - ALPN ClientHello Handshake Message ServerHello ALPN Extention 通信プロトコル候補
ALPN Extention 通信プロトコル決定 Negotiation 暗号化
暗号化 Negotiation h2 - NPN ClientHello Handshake Message ServerHello NPN
Extention 通信プロトコル候補 NPN Extention 通信プロトコル決定
Binary Frame https://developers.google.com/web/fundamentals/performance/http2/
Binary Frame TYPE FRAME DESCRIPTION 0 DATA リクエスト/レスポンスの本文 1 HEADERS
リクエスト/レスポンスのヘッダ情報 2 PRIORITY ストリーム優先順位(※クライアントのみ送信可) 3 RST_STREAM ストリーム終了(※エラー時など) 4 SETTINGS 接続設定の変更 5 PUSH_PROMISE サーバプッシュ予告(※サーバのみ送信可) 6 PING 接続の生存状態を確認 7 GOAWAY 接続終了(※エラー時など) 8 WINDOW_UPDATE ウインドウサイズ変更 9 CONTINUATION サイズの大きい HEADERS / PUSH_PROMISE フレーム断片
リクエストヘッダの基本形 Header Compression GET /index.html HTTP/1.1 Host: ariaki.info : HTTP/1.1
:method GET :path / :scheme https :authority ariaki.info Accept */* : HTTP/2
リクエストヘッダの送信方法 Header Compression - ヘッダ情報はキャッシュ ( Reference Set ) し、2
回目以降は差分送信 - ヘッダ名は別途管理 ( Table ) し、2 回目以降は Index 指定 - Table 最大長は SETTINGS_MAX_HEADER_LIST_SIZE で指定 - 超過した場合は FIFO で削除 - ヘッダは Binary 形式 ( Binary Optimized Header Encoding ) - HPACK 圧縮
リクエストヘッダ テーブル Header Compression - Index, Name, Value を持つテーブル構造 -
静的テーブル - 使用頻度の高いヘッダ - Index ( 1 - 61 ) が規定されている - 動的テーブル - その他のヘッダデータ - Index ( 62 - ) を自動採番する - 2回目以降は Index を使って指定する
静的テーブル ( 一部抜粋 ) Header Compression +-------+-----------------------------+---------------+ | Index |
Header Name | Header Value | +-------+-----------------------------+---------------+ | 1 | :authority | | | 2 | :method | GET | | 3 | :method | POST | | 4 | :path | / | | 5 | :path | /index.html | | 6 | :scheme | http | | 7 | :scheme | https | | 8 | :status | 200 | | 9 | :status | 204 | | 10 | :status | 206 | | 11 | :status | 304 | | 12 | :status | 400 | | 13 | :status | 404 | | 14 | :status | 500 | | 15 | accept-charset | | +-------+-----------------------------+---------------+ | Index | Header Name | Header Value | +-------+-----------------------------+---------------+ | 16 | accept-encoding | gzip, deflate | | 17 | accept-language | | | 18 | accept-ranges | | | 19 | accept | | | 20 | access-control-allow-origin | | | 21 | age | | | 22 | allow | | | 23 | authorization | | | 24 | cache-control | | | 25 | content-disposition | | | 26 | content-encoding | | | 27 | content-language | | | 28 | content-length | | | 29 | content-location | | | 30 | content-range | | https://tools.ietf.org/html/draft-ietf-httpbis-header-compression-12#appendix-A
テーブル指定 Header Compression +-------+-----------------------------+---------------+ | Index | Header Name |
Header Value | +-------+-----------------------------+---------------+ | 1 | :authority | | | 2 | :method | GET | | 4 | :path | / | | 7 | :scheme | https | :method GET :path / :scheme https :authority ariaki.info x-test-header DEBUG : 2 GET 4 / 7 https 1 ariaki.info x-test-header DEBUG ( ※次回以降は 62 を指定 ) :
概要 Multi Plexing - HTTP/1.1 - セッション毎に 1 リクエストずつ処理 -
同一ドメインに対して同時 6 セッション / Google Chrome - 複数ドメインに対して同時 2 セッション / HTTP 推奨仕様 - サーバはリクエストの順番通りに返却しなければならない - HTTP/2 - 同一セッション内で同時に複数 ( 100+ ) リクエスト可 - リクエスト時にレスポンス優先順位を設定可
Multi Plexing HTTP/1.1 HTTP/2 (1) GET /index.html (2) GET /app.css
(3) GET /app.js (1) GET /index.html (2) GET /app.css (3) GET /app.js (4) GET /logo.png (4) GET /logo.png 1セッション内で 複数リクエスト 複数セッションを 平行リクエスト * Response all
Server Push GET /index.html /index.html /app.css /app.js /logo.png サーバが判断し、必要に応じて追加リソースを一括返却 HTTP/2
HTTP/2 の課題 Problems - Head of Line Blocking 問題 -
レスポンス完了まで後続のリクエストを受け付けられない - 小さなレスポンス圧縮によるサイドチャネル攻撃 - CRIME / BREACH 等 - Server Push: キャッシュ済データを送信する問題 - 103 Early Hints 等で改善中 - Priority: 優先度を喋らないクライアントに対する応答方法がサーバ実装任せ
その他 Otherwise - WEB 界隈はセキュリティ強化がホットな状況 - TLS 1.3 : draft
28 が IETF 正式勧告 ( OpenSSL 等が対応済 ) - DoH : いくつかの Public DNS が対応開始 - QUIC : まだ 1 年以上かかりそう
HTTP/2 Compatibility
https://caniuse.com/#feat=http2
OSS Server Products Compatibility - Apache HTTP Server 2.4.17+ (
mod_http2 ) - nginx 1.9.5+ - OpenSSL 1.0.2+ - NodeJS 9+ ( node-http2 ) - Apache Tomcat 8.5.32+ ( and more )
Now you can use HTTP/2 on your site.
Appendix - https://developers.google.com/web/fundamentals/performance/http2/?hl=ja - https://tools.ietf.org/html/rfc7540 - https://mozilla.github.io/meao/2017/06/26/http2/ - https://developer.mozilla.org/ja/docs/Web/HTTP/Overview -
https://http2.redbox.ne.jp
@ariaki4dev Written by
http://bit.ly/bc2018ariaki に登壇応募 ( CfP ) しています 拡散にご協力ください