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
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
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.8k
アウトプットを始めよう / How to begin output jawsug-bgnr
ariaki
2
4.1k
参加者の安全を守れていますか? / Protecting community safety
ariaki
1
7.7k
タピオカに学ぶ二段階認証 / tapioca-mfa
ariaki
5
1.4k
古に学ぶ個人開発のススメ / My recommendation of personal development
ariaki
1
1.6k
Other Decks in Technology
See All in Technology
CIで使うClaude
iwatatomoya
0
170
AI Agent SaaS を支える自社仮想化基盤への挑戦と実運用 / ai-agent-saas-virtualization
flatt_security
2
3k
SRE依存からの脱却 運用を開 発チームへ移す、 フルサイ クル開 発体制の実践
joooee0000
0
1.9k
スタートアップにおけるアジャイルの実践について #shibuyagile
murabayashi
3
2.1k
人を動かすのは時間ではなく、納得感 〜新任EMが入社3ヶ月、組織を2回変えた話〜
kakehashi
PRO
3
170
なぜ人は自分のプロジェクトを 「なんちゃってアジャイル」と 自嘲するのか
kozotaira
0
260
初めてのDatabricks勉強会
taka_aki
2
240
Foxgloveについて 実際にExtensionを開発して公開するまでの話 / About Foxglove: The Story of Developing and Releasing an Extension
ry0_ka
0
180
環境凍結という Toil を倒す -セルフサービス型 Ephemeral テスト環境の 設計と実践
shirouz
1
1.6k
Claude Codeとハーネスについて考えてみる
oikon48
18
8.8k
脱金融のフューチャー・デザイン / Future Design Beyond Finance
ks91
PRO
0
140
AI時代のエンジニアキャリアについて今一度考える
sakamoto_582
2
1.3k
Featured
See All Featured
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.2k
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
63
55k
4 Signs Your Business is Dying
shpigford
187
22k
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
340
YesSQL, Process and Tooling at Scale
rocio
174
15k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
310
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
280
Skip the Path - Find Your Career Trail
mkilby
1
160
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.2k
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
2.9k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
220
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
460
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 ) しています 拡散にご協力ください