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
HTTP2とASGI Webサーバの関係 - Hypercornを例に
Search
Junya Fukuda
October 10, 2020
Programming
0
1.3k
HTTP2とASGI Webサーバの関係 - Hypercornを例に
PyCon mini Hiroshima 2020 登壇資料
Junya Fukuda
October 10, 2020
Tweet
Share
More Decks by Junya Fukuda
See All by Junya Fukuda
プロダクションでのPython非同期ユースケース - Trio/Trio-Utilを中心に
jrfk
2
150
Event-Driven asyncio: A Case Study of Trio's API(PyCon US 2024)
jrfk
1
140
EuroPython 2023体験記 - 非英語話者の海外登壇@みんなのPython勉強会#98
jrfk
0
190
Asyncio Evolved: Enhanced Exception Handling with TaskGroup in Python 3.11(PyConTW 2023)
jrfk
0
37
Asyncio Evolved: Enhanced Exception Handling with TaskGroup in Python 3.11(EuroPython 2023)
jrfk
3
1.2k
Django 4.1のAsynchronous
jrfk
1
2.3k
New in Python 3.11: asyncio.TaskGroup and “Hello-ish World” of Asyncio
jrfk
0
480
Python3.11新機能asyncio.TaskGroup()と2022年asyncioの"Hello-ish world"
jrfk
3
3.8k
こわくないasyncio基礎と非同期IO - 動くコードを添えて
jrfk
0
790
Other Decks in Programming
See All in Programming
RubyLSPのマルチバイト文字対応
notfounds
0
120
카카오페이는 어떻게 수천만 결제를 처리할까? 우아한 결제 분산락 노하우
kakao
PRO
0
110
Outline View in SwiftUI
1024jp
1
320
シェーダーで魅せるMapLibreの動的ラスタータイル
satoshi7190
1
480
Tauriでネイティブアプリを作りたい
tsucchinoko
0
370
タクシーアプリ『GO』のリアルタイムデータ分析基盤における機械学習サービスの活用
mot_techtalk
4
1.4k
광고 소재 심사 과정에 AI를 도입하여 광고 서비스 생산성 향상시키기
kakao
PRO
0
170
WebフロントエンドにおけるGraphQL(あるいはバックエンドのAPI)との向き合い方 / #241106_plk_frontend
izumin5210
4
1.4k
見せてあげますよ、「本物のLaravel批判」ってやつを。
77web
7
7.7k
Jakarta EE meets AI
ivargrimstad
0
510
ピラミッド、アイスクリームコーン、SMURF: 自動テストの最適バランスを求めて / Pyramid Ice-Cream-Cone and SMURF
twada
PRO
10
1.3k
Jakarta Concurrencyによる並行処理プログラミングの始め方 (JJUG CCC 2024 Fall)
tnagao7
1
290
Featured
See All Featured
GitHub's CSS Performance
jonrohan
1030
460k
GraphQLの誤解/rethinking-graphql
sonatard
67
10k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.8k
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.2k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
5 minutes of I Can Smell Your CMS
philhawksworth
202
19k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
410
Practical Orchestrator
shlominoach
186
10k
How To Stay Up To Date on Web Technology
chriscoyier
788
250k
Put a Button on it: Removing Barriers to Going Fast.
kastner
59
3.5k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.3k
For a Future-Friendly Web
brad_frost
175
9.4k
Transcript
)551ͱ"4(*8FCαʔόͷؔ )ZQFSDPSOΛྫʹ Junya Fukuda PyCon mini Hiroshima 2020
썡쎕썟썷쎣쎟 •ా ൏ʢJunya Fukudaʣʢ@JunyaFffʣ •גࣜձࣾຊγεςϜٕݚʢJSLʣॴଐ ݝͷձࣾ •ੜ·Εౡݝͷ͓ྡɺࢁޱݝ •GEEKLAB.NAGANO •࠷ۙϚΠϯΫϥϑτͰখֶੜ͚Youtube৴࢝ΊΔ ΪʔΫϥϘϚΠΫϥ
ຊ쏅쏍쏁쏱쏽쎅ྲྀ쎣 •ASGIͬͯͳʹʁ •HTTP/2ͬͯͳʹʁ •Hypercorn×FastAPIͰετϦʔϜ •Hypercorn×FastAPIΛͬͨHTTP/1.1 HTTP/2ੑೳଌఆ
1ZUIPO8FCͰ )551Λҙࣝͨ͜͠ͱ ͋Γ·͔͢ʁ
쏬쏋쏣썗쏁쏱쏽썿쎾썗쏵 •HTTP/2Λҙࣝͨ͜͠ͱ͋·Γͳ͍ •σϓϩΠڥʹϦόʔεϓϩΩγ͍Δ͠ɺHTTP/2ؾʹ͢Δͷͦ͘͜Β͍
쏬쏋쏣썗쏁쏱쏽썿쎾썗쏵 •HTTP/2Λҙࣝͨ͜͠ͱ͋·Γͳ͍ •σϓϩΠڥʹϦόʔεϓϩΩγ͍Δ͠ɺHTTP/2ؾʹ͢Δͷͦ͘͜Β͍ •ϩʔυόϥϯαʔ ͷଆHTTP/1.1Ͱे
쏬쏋쏣썗쏁쏱쏽썿쎾썗쏵 •HTTP/2Λҙࣝͨ͜͠ͱ͋·Γͳ͍ •σϓϩΠڥʹϦόʔεϓϩΩγ͍Δ͠ɺHTTP/2ؾʹ͢Δͷͦ͘͜Β͍ •ϩʔυόϥϯαʔ ͷଆHTTP/1.1Ͱे •ʢPure Python ͷWebαʔόͳΜͯʣ
쏬쏋쏣썗쏁쏱쏽썿쎾썗쏵 •HTTP/2Λҙࣝͨ͜͠ͱ͋·Γͳ͍ •σϓϩΠڥʹϦόʔεϓϩΩγ͍Δ͠ɺHTTP/2ؾʹ͢Δͷͦ͘͜Β͍ •ϩʔυόϥϯαʔ ͷଆHTTP/1.1Ͱे •ͦΜͳͳ͔ɺASGIͱHypercornͱग़ձͬͨ •Python WebͰHTTP/2ʹ͢Δͱͳʹ͕͓͍͍͠ͷʁ •ʢPure Python
ͷWebαʔόͳΜͯʣ
쏬쏋쏣썗쏁쏱쏽썿쎾썗쏵 •HTTP/2Λҙࣝͨ͜͠ͱ͋·Γͳ͍ •σϓϩΠڥʹϦόʔεϓϩΩγ͍Δ͠ɺHTTP/2ؾʹ͢Δͷͦ͘͜Β͍ •ϩʔυόϥϯαʔ ͷଆHTTP/1.1Ͱे •ͦΜͳͳ͔ɺASGIͱHypercornͱग़ձͬͨ •Python WebͰHTTP/2ʹ͢Δͱͳʹ͕͓͍͍͠ͷʁ •ʢPure Python
ͷWebαʔόͳΜͯʣ •HTTP/3 RFCલɻ࠷ޙʂʁͷHTTP/2ωλ
"4(*ͬͯͳʹʁ
"4(*썺썽쎁쎂 •Asynchronous Server Gateway Interface ͷུ •WSGIͷޙܧ •WebαʔόͱΞϓϦέʔγϣϯͷΠϯλʔϑΣʔεͷ༷
"4(*썺썽쎁쎂 •Asynchronous Server Gateway Interface ͷུ •Webαʔό͕ΞϓϦέʔγϣϯͷ async/await ʹରԠ •WSGIͷޙܧ
•WebαʔόͱΞϓϦέʔγϣϯͷΠϯλʔϑΣʔεͷ༷
"4(*썺썽쎁쎂 •Asynchronous Server Gateway Interface ͷུ •Webαʔό͕ΞϓϦέʔγϣϯͷ async/await ʹରԠ •WSGIͷޙܧ
•WebαʔόͱΞϓϦέʔγϣϯͷΠϯλʔϑΣʔεͷ༷ https://www.youtube.com/watch?v=EwG5EWKu8nw ASGIʢඇಉظαʔόήʔτΣΠΠϯλʔϑΣʔεʣͷ֓ཁ (Junya Fukuda) [PyCon JP 2020]
"4(*썺썽쎁쎂 •Asynchronous Server Gateway Interface ͷུ •Webαʔό͕ΞϓϦέʔγϣϯͷ async/await ʹରԠ •WSGIͷޙܧ
•WebαʔόͱΞϓϦέʔγϣϯͷΠϯλʔϑΣʔεͷ༷ https://www.youtube.com/watch?v=EwG5EWKu8nw ASGIʢඇಉظαʔόήʔτΣΠΠϯλʔϑΣʔεʣͷ֓ཁ (Junya Fukuda) [PyCon JP 2020] •ෳͷҰൠతͳϓϩτίϧΛॲཧՄೳʮHTTP/1.1ʯʮHTTP/2ʯʮWebsocketʯ
"4(*썺썽쎁쎂 •දతͳASGIؔ࿈ͷαʔόͱϑϨʔϜϫʔΫ
)551ͬͯͳʹʁ
)551썺썽쎁쎂 •HTTP/̍.1͔Β16ͷࡀ݄Λܦͯɺ2015ʹRFC •վળΛతͱ༷ͨ͠
)551썺썽쎁쎂 •HTTP/̍.1͔Β16ͷࡀ݄Λܦͯɺ2015ʹRFC •αʔόαΠυϓογϡ •ϔομʔͷѹॖ •ετϦʔϜʢϦΫΤετͷଟॏԽʣ •վળΛతͱ༷ͨ͠
)551썺썽쎁쎂 •HTTP/̍.1͔Β16ͷࡀ݄Λܦͯɺ2015ʹRFC •αʔόαΠυϓογϡ •ϔομʔͷѹॖ •ετϦʔϜʢϦΫΤετͷଟॏԽʣ •վળΛతͱ༷ͨ͠
)551썺썽쎁쎂 •ετϦʔϜ
)551썺썽쎁쎂 •ετϦʔϜ ‣ HTTP/̍.1ͷΛղܾ͢ΔͨΊͷ༷ •1ͭͷϦΫΤετ͕ྃ͢Δ·Ͱݪଇɺ࣍ͷϦΫΤετΛૹΕͳ͍
)551썺썽쎁쎂 ‣ HTTP/̍.1ͷΛղܾ͢ΔͨΊͷ༷ •1ͭͷϦΫΤετ͕ྃ͢Δ·Ͱݪଇɺ࣍ͷϦΫΤετΛૹΕͳ͍ ‣ ΫϥΠΞϯτ ‣ αʔόʔ
)551썺썽쎁쎂 ‣ HTTP/̍.1ͷΛղܾ͢ΔͨΊͷ༷ •1ͭͷϦΫΤετ͕ྃ͢Δ·Ͱݪଇɺ࣍ͷϦΫΤετΛૹΕͳ͍ ‣ ΫϥΠΞϯτ ‣ αʔόʔ
)551썺썽쎁쎂 ‣ HTTP/̍.1ͷΛղܾ͢ΔͨΊͷ༷ •1ͭͷϦΫΤετ͕ྃ͢Δ·Ͱݪଇɺ࣍ͷϦΫΤετΛૹΕͳ͍ ‣ ΫϥΠΞϯτ ‣ αʔόʔ
)551썺썽쎁쎂 ‣ HTTP/̍.1ͷΛղܾ͢ΔͨΊͷ༷ •1ͭͷϦΫΤετ͕ྃ͢Δ·Ͱݪଇɺ࣍ͷϦΫΤετΛૹΕͳ͍ ‣ ΫϥΠΞϯτ ‣ αʔόʔ
)551썺썽쎁쎂 ‣ HTTP/̍.1ͷΛղܾ͢ΔͨΊͷ༷ •1ͭͷϦΫΤετ͕ྃ͢Δ·Ͱݪଇɺ࣍ͷϦΫΤετΛૹΕͳ͍ ‣ ΫϥΠΞϯτ ‣ αʔόʔ
)551썺썽쎁쎂 ‣ HTTP/̍.1ͷΛղܾ͢ΔͨΊͷ༷ •1ͭͷϦΫΤετ͕ྃ͢Δ·Ͱݪଇɺ࣍ͷϦΫΤετΛૹΕͳ͍ ‣ ΫϥΠΞϯτ ‣ αʔόʔ HTTP/̍.1ͷϦΫΤετ-Ϩεϙ ϯεɺৗʹॱ൪Λอͪಉظత
ʹߦΘΕΔඞཁ͕͋Δ
)551썺썽쎁쎂 ‣ HTTP/̍.1ͷΛղܾ͢ΔͨΊͷ༷ •1ͭͷϦΫΤετ͕ྃ͢Δ·Ͱݪଇɺ࣍ͷϦΫΤετΛૹΕͳ͍ ‣ ΫϥΠΞϯτ ‣ αʔόʔ HTTP/̍.1ͷϦΫΤετ-Ϩεϙ ϯεɺৗʹॱ൪Λอͪಉظత
ʹߦΘΕΔඞཁ͕͋Δ WebγεςϜͰ ը໘දࣔ࣌ʹ80ϦΫΤετ
)551썺썽쎁쎂 ‣ ྫ͑օ͞Μ͕͍ͬͯΔGmail
)551썺썽쎁쎂 ‣ HTTP/̍.1ͷΛղܾ͢ΔͨΊͷ༷ •1ͭͷϦΫΤετ͕ྃ͢Δ·Ͱݪଇɺ࣍ͷϦΫΤετΛૹΕͳ͍ ‣ ΫϥΠΞϯτ ‣ αʔόʔ ‣ TCP
× 6ຊ
)551썺썽쎁쎂 ‣ HTTP/̍.1ͷΛղܾ͢ΔͨΊͷ༷ •1ͭͷϦΫΤετ͕ྃ͢Δ·Ͱݪଇɺ࣍ͷϦΫΤετΛૹΕͳ͍ ‣ ΫϥΠΞϯτ ‣ αʔόʔ
)551썺썽쎁쎂 •ετϦʔϜ ‣ ΫϥΠΞϯτ ‣ αʔόʔ ‣ ΫϥΠΞϯτ ‣ αʔόʔ
HTTP/1.1 HTTP/2
)551썺썽쎁쎂 •ετϦʔϜ ‣ ΫϥΠΞϯτ ‣ αʔόʔ ‣ ΫϥΠΞϯτ ‣ αʔόʔ
HTTP/1.1 HTTP/2
)551썺썽쎁쎂 •ετϦʔϜ ‣ ΫϥΠΞϯτ ‣ αʔόʔ ‣ ΫϥΠΞϯτ ‣ αʔόʔ
‣ 1ͭͷTCPͷίωΫγϣϯͷதͰॱ൪ͪΛ͢Δ͜ͱͳ͘ɺฒྻʹॲཧ HTTP/1.1 HTTP/2 ฒྻʹॲཧ
)551썺썽쎁쎂 •ετϦʔϜ ‣ ΫϥΠΞϯτ ‣ αʔόʔ ‣ ΫϥΠΞϯτ ‣ αʔόʔ
HTTP/1.1 HTTP/2 ฒྻʹॲཧ ‣ 1ͭͷTCPͷίωΫγϣϯͷதͰॱ൪ͪΛ͢Δ͜ͱͳ͘ɺฒྻʹॲཧ
)551쎂ରԠ썮썶"4(*8FC4FSWFS •ASGI Web ServerͷҰཡ Daphne Mangum IUUQTHJUIVCDPNqPSJNPOENBODBBXFTPNFBTHJ
)551쎂ରԠ썮썶"4(*8FC4FSWFS •ASGI WebServer ͱ͍͑ Uvicorn •·ͩHTTP/2ະରԠ ʢରԠ༧ఆ͋Γʣ Uvicorn currently supports
HTTP/1.1 and WebSockets. Support for HTTP/2 is planned. UvicornݱࡏɺHTTP/1.1ͱWebSocketsΛαϙʔτ͍ͯ͠·͢ɻ HTTP/2ͷαϙʔτ͕༧ఆ͞Ε͍ͯ·͢ɻ
)551쎂ରԠ썮썶"4(*8FC4FSWFS •ASGI༷ͷରԠঢ়گ Framework HTTP WebSockets Server Push WebSocket HTTP Hypercorn
1 ◦ 2 ◦ 1 ◦ 2 ◦ ◦ ◦ Uvicorn 1 ◦ 2 × 1 ◦ 2 × × × Daphne 1 ◦ 2 ◦ 1 ◦ 2 × × × Mangum 1 ◦ 2 × 1 ◦ 2 × × ×
)551쎂ରԠ썮썶"4(*8FC4FSWFS •ASGI༷ͷରԠঢ়گ Framework HTTP WebSockets Server Push WebSocket HTTP Hypercorn
1 ◦ 2 ◦ 1 ◦ 2 ◦ ◦ ◦ Uvicorn 1 ◦ 2 × 1 ◦ 2 × × × Daphne 1 ◦ 2 ◦ 1 ◦ 2 × × × Mangum 1 ◦ 2 × 1 ◦ 2 × × ×
)551쎂ରԠ썮썶"4(*8FC4FSWFS •ϋΠύʔίʔϯͱಡΈ·͢ •WSGI Web αʔόͷGunicornʹΠϯεύΠΞ͞Ε͍ͯΔ •HTTP / 1ɺHTTP / 2ɺWebSocketʢHTTP
/ 1͓ΑͼHTTP / 2ܦ༝ʣαϙʔτ •worker ͷλΠϓʹ asyncio,uvloop,trio ΛࢦఆՄೳ •worker ΛࢦఆՄೳ
ຊ쏅쏍쏁쏱쏽썾쎅)551쎅썛ಓ •HTTP/2αʔόͱΞϓϦέʔγϣϯͷϦΫΤετɾϨεϙϯεʹண •੩తϑΝΠϧͷ৴ผͰɻΦϒδΣΫτετϨʔδCDNͰ
ຊ쏅쏍쏁쏱쏽썾쎅)551쎅썛ಓ ͷίϯςφ࣌ͷ1ZUIPOΞʔΩςΫνϟσϓϩΠ TIJCVLBXB <1Z$PO+1> IUUQTXXXZPVUVCFDPNXBUDI W0Y3O%-6OP*TUBSU •HTTP/2αʔόͱΞϓϦέʔγϣϯͷϦΫΤετɾϨεϙϯεʹண •੩తϑΝΠϧͷ৴ผͰɻΦϒδΣΫτετϨʔδCDNͰ
)ZQFSDPSOΛྫʹ ετϦʔϜʢଟॏԽʣΛ
)ZQFSDPSO썾쏃쏒쏴썗쏪 •؆୯ͳWebΞϓϦέʔγϣϯΛHypercornͰಈ͔͢ •ϒϥβ͔ΒJavascriptͰΞΫηε •WebΞϓϦέʔγϣϯͷίʔυಉ͡ •HTTP/1.1ͱHTTP/2ͷҧ͍ΛɺΈͯΈ·͠ΐ͏
ڥ •Hypercorn •fastapi 0.61.1 0.11.0 Webαʔό Web Framework ⁶ ⁶
ʢASGIʣ ʢHTTP/2ʣ ʢHTTP/1.1ʣ )ZQFSDPSO썾쏃쏒쏴썗쏪
ڥ •Hypercorn •fastapi 0.61.1 0.11.0 Webαʔό Web Framework ⁶ ⁶
ʢASGIʣ ʢHTTP/2ʣ ʢHTTP/1.1ʣ )ZQFSDPSO썾쏃쏒쏴썗쏪
쎿썗쏚쎿쎮쏓쎅ॲཧ @app.get("/message/{id}") async def get_message(id:str): await asyncio.sleep(3) return {"text": f"spam,
egg, spam and spam!, {id}!"}
쎹쏳쎮쎬쏽쏒쎅ॲཧ requestButton.onclick = async function() { result = []; for
(let i = 0; i < 24; i++) { result.push(fetch(`/message/${i}/`)); } await Promise.all(result); }
)551쎅߹
)551쎅߹
)551쎅߹
)551쎅߹ TFDˎຊ
)551쎅߹ TFDˎຊ TFDˎຊ
)551쎅߹ TFDˎຊ TFDˎຊ TFDˎຊ
)551쎅߹ TFDˎຊ TFDˎຊ TFDˎຊ TFDˎຊ
)551쎅߹ TFDˎຊ TFDˎຊ TFDˎຊ TFDˎຊ τʔλϧTFD
)551쎅߹
)551쎅߹
)551쎅߹ TFDˎຊ
)551쎅߹ TFDˎຊ τʔλϧTFD
)551ͱ)551̍ ੑೳΛൺֱ
)551)551쏛쏟쎳썗쏨쏽쏃ൺֱ •࣮ߦڥϩʔΧϧϚγϯ •ࢦඪɺॲཧͷऴྃ·Ͱʹ͔͔ͬͨ࣌ؒʗ1ඵ͋ͨΓʹࡹ͚ΔϦΫΤετ •ੑೳଌఆπʔϧͱͯ͠ɺh2load ίϚϯυΛ༻͢Δ •؆୯ͳWebΞϓϦέʔγϣϯΛHypercornͰಈ͔͢
)551)551쏛쏟쎳썗쏨쏽쏃ൺֱ αʔό HTTP/1.1 HTTP/2 •Hypercorn •fastapi 0.61.1 0.11.0 Webαʔό Web
Framework ⁶ ⁶ ʢASGIʣ ʢHTTP/2ʣ ʢHTTP/1.1ʣ
)551)551쏛쏟쎳썗쏨쏽쏃ൺֱ αʔό HTTP/1.1 HTTP/2 •Hypercorn •fastapi 0.61.1 0.11.0 Webαʔό Web
Framework ⁶ ⁶ ʢASGIʣ ʢHTTP/2ʣ ʢHTTP/1.1ʣ
ϋʔυΣΞڥ •Macbook Pro •2.6 GHz 6ίΞ Intel Core i7 •ϝϞϦ
16GB )551)551쏛쏟쎳썗쏨쏽쏃ൺֱ
)551)551쏛쏟쎳썗쏨쏽쏃ൺֱ •h2load ίϚϯυ Φϓγϣϯ ҙຯ -n ૯ϦΫΤετ -c ΫϥΠΞϯτɻಉ࣌ΞΫηε -p
ϓϩτίϧʢࣗಈผʣ •h2load -c 100 -n 10000 https://127.0.0.1:8000/query
)551)551쏛쏟쎳썗쏨쏽쏃ൺֱ ҎԼ3ͭ݅ •ΫϥΠΞϯτಉ࣌ଓ 10, ϦΫΤετ 100 •ΫϥΠΞϯτಉ࣌ଓ 50, ϦΫΤετ 5000
•ΫϥΠΞϯτಉ࣌ଓ 100, ϦΫΤετ 10000
)551)551쏛쏟쎳썗쏨쏽쏃ൺֱ ҎԼ3ͭ݅ •ΫϥΠΞϯτಉ࣌ଓ 10, ϦΫΤετ 100 •ΫϥΠΞϯτಉ࣌ଓ 50, ϦΫΤετ 5000
•ΫϥΠΞϯτಉ࣌ଓ 100, ϦΫΤετ 10000 ࢦඪ •ॲཧͷऴྃ·Ͱʹ͔͔ͬͨ࣌ؒ •1ඵ͋ͨΓͷॲཧͨ͠ϦΫΤετ
)551)551쏛쏟쎳썗쏨쏽쏃ൺֱ ҎԼ3ͭ݅ •ΫϥΠΞϯτಉ࣌ଓ 10, ϦΫΤετ 100 •ΫϥΠΞϯτಉ࣌ଓ 50, ϦΫΤετ 5000
•ΫϥΠΞϯτಉ࣌ଓ 100, ϦΫΤετ 10000 ࢦඪ •ॲཧͷऴྃ·Ͱʹ͔͔ͬͨ࣌ؒ •1ඵ͋ͨΓͷॲཧͨ͠ϦΫΤετ → ૣ͍ͱྑ͍ → ଟ͍ͱྑ͍
)551)551쏛쏟쎳썗쏨쏽쏃ൺֱ •ΫϥΠΞϯτಉ࣌ଓ 10, ϦΫΤετ 100
)551)551쏛쏟쎳썗쏨쏽쏃ൺֱ ऴྃ࣌ؒ [s] •ΫϥΠΞϯτಉ࣌ଓ 10,
ϦΫΤετ 100
)551)551쏛쏟쎳썗쏨쏽쏃ൺֱ ऴྃ࣌ؒ [s] •ΫϥΠΞϯτಉ࣌ଓ 10,
ϦΫΤετ 100 ϦΫΤετ [s]
)551)551쏛쏟쎳썗쏨쏽쏃ൺֱ ऴྃ࣌ؒ [s] •ΫϥΠΞϯτಉ࣌ଓ 10,
ϦΫΤετ 100 ϦΫΤετ [s] HTTP/1.1 HTTP/2 HTTP/1.1 HTTP/2
None
)551)551쏛쏟쎳썗쏨쏽쏃ൺֱ ऴྃ࣌ؒ [s] •ΫϥΠΞϯτಉ࣌ଓ 10,
ϦΫΤετ 100 ϦΫΤετ [s] HTTP/1.1 HTTP/2 HTTP/1.1 HTTP/2
)551)551쏛쏟쎳썗쏨쏽쏃ൺֱ •ΫϥΠΞϯτಉ࣌ଓ 50, ϦΫΤετ 5000
ऴྃ࣌ؒ [s] ϦΫΤετ [s] HTTP/1.1 HTTP/2 HTTP/1.1 HTTP/2
)551)551쏛쏟쎳썗쏨쏽쏃ൺֱ •ΫϥΠΞϯτಉ࣌ଓ 100, ϦΫΤετ 10000
ऴྃ࣌ؒ [s] ϦΫΤετ [s] HTTP/1.1 HTTP/2 HTTP/1.1 HTTP/2
None
)551썺썽쎁쎂 •HTTP/̍.1͔Β16ͷࡀ݄Λܦͯɺ2015ʹRFC •αʔόαΠυϓογϡ •ϔομʔͷѹॖ •ετϦʔϜʢϦΫΤετͷଟॏԽʣ •վળΛతʹ༷ͨ͠
)551썺썽쎁쎂 •HTTP/̍.1͔Β16ͷࡀ݄Λܦͯɺ2015ʹRFC •αʔόαΠυϓογϡ •ϔομʔͷѹॖ •ετϦʔϜʢϦΫΤετͷଟॏԽʣ •վળΛతʹ༷ͨ͠
)551)551쏛쏟쎳썗쏨쏽쏃ൺֱ •h2load — help Max concurrent streams to issue per
session. When http/1.1 is used, this specifies the number of HTTP pipelining requests in-flight. ηογϣϯ͝ͱʹൃߦ͢Δ࠷େಉ࣌ετϦʔϜɻ http/1.1 Λ༻͢Δ߹ɺ HTTP ύΠϓϥΠϯϦΫΤετ ͷΛࢦఆ͠·͢ɻ -m, --max-concurrent-streams=<N>
)551)551쏛쏟쎳썗쏨쏽쏃ൺֱ •ΫϥΠΞϯτಉ࣌ଓ 10, ϦΫΤετ 100, ετϦʔϜ 5
)551)551쏛쏟쎳썗쏨쏽쏃ൺֱ ऴྃ࣌ؒ [s] •ΫϥΠΞϯτಉ࣌ଓ 10,
ϦΫΤετ 100, ετϦʔϜ 5
)551)551쏛쏟쎳썗쏨쏽쏃ൺֱ ऴྃ࣌ؒ [s] •ΫϥΠΞϯτಉ࣌ଓ 10,
ϦΫΤετ 100, ετϦʔϜ 5 ϦΫΤετ [s]
)551)551쏛쏟쎳썗쏨쏽쏃ൺֱ ऴྃ࣌ؒ [s] •ΫϥΠΞϯτಉ࣌ଓ 10,
ϦΫΤετ 100, ετϦʔϜ 5 ϦΫΤετ [s] HTTP/1.1 HTTP/2 HTTP/1.1 HTTP/2
)551)551쏛쏟쎳썗쏨쏽쏃ൺֱ •ΫϥΠΞϯτಉ࣌ଓ 50, ϦΫΤετ 5000,
ετϦʔϜ 5 ऴྃ࣌ؒ [s] ϦΫΤετ [s] HTTP/1.1 HTTP/2 HTTP/1.1 HTTP/2
)551)551쏛쏟쎳썗쏨쏽쏃ൺֱ •ΫϥΠΞϯτಉ࣌ଓ 100, ϦΫΤετ 10000,
ετϦʔϜ 5 ऴྃ࣌ؒ [s] ϦΫΤετ [s] HTTP/1.1 HTTP/2 HTTP/1.1 HTTP/2
)551)551쏛쏟쎳썗쏨쏽쏃ൺֱ ετϦʔϜͳ͠ ετϦʔϜ͋Γ •ΫϥΠΞϯτಉ࣌ଓ 100,
ϦΫΤετ 10000, ετϦʔϜ 5 ετϦʔϜͳ͠ ετϦʔϜ͋Γ ऴྃ࣌ؒ [s] ϦΫΤετ [s] HTTP/1.1 HTTP/2 HTTP/1.1 HTTP/2
쎕썿쎘 •ϦΫΤετͷଟॏԽ͕͞Ε͍ͯΔͱ͜ΖͰ͋ΕHTTP/2ɺ͍
쎕썿쎘 •WebαΠτͷ1ճͷΞΫηεͰɺෳճαʔόϦΫΤετΛ߹ •ϦΫΤετͷଟॏԽ͕͞Ε͍ͯΔͱ͜ΖͰ͋ΕHTTP/2ɺ͍
쎕썿쎘 → γεςϜࢹμογϡϘʔυ •WebαΠτͷ1ճͷΞΫηεͰɺෳճαʔόϦΫΤετΛ߹ → ϦΞϧλΠϜσʔλ → νϟοτΞϓϦ •ϦΫΤετͷଟॏԽ͕͞Ε͍ͯΔͱ͜ΖͰ͋ΕHTTP/2ɺ͍
쎕썿쎘 → γεςϜࢹμογϡϘʔυ •WebαΠτͷ1ճͷΞΫηεͰɺෳճαʔόϦΫΤετΛ߹ → ϦΞϧλΠϜσʔλ → νϟοτΞϓϦ •طଘͷαΠτͰܧ͗͠ܧ͗͠ʹͳͬͯ͠·͍ͬͯΔ߹ʢΉͳ͘ʣ •ϦΫΤετͷଟॏԽ͕͞Ε͍ͯΔͱ͜ΖͰ͋ΕHTTP/2ɺ͍
쎕썿쎘 •HTTP/2Կ͕͓͍͍͠ͷʁ
쎕썿쎘 •HTTP/2Կ͕͓͍͍͠ͷʁ → ͕վળͷՄೳੑ
쎕썿쎘 •HTTP/2Կ͕͓͍͍͠ͷʁ •ࣗ͝ͷPython Web Application Λ͝ཡʹͳͬͯΈ͍ͯͩ͘͞ɻ •ϒϥβͷσόοΨΛ։͍ͯϦϩʔυ → ͕վળͷՄೳੑ
쎕썿쎘 •HTTP/2Կ͕͓͍͍͠ͷʁ •ࣗ͝ͷPython Web Application Λ͝ཡʹͳͬͯΈ͍ͯͩ͘͞ɻ •ϒϥβͷσόοΨΛ։͍ͯϦϩʔυ •Protocol=HTTP/1.1ʹͳ͍ͬͯΔʢLBͷଆ͕HTTP/1.1ͷՄೳੑʣ → ͕վળͷՄೳੑ
쎕썿쎘 •HTTP/2Կ͕͓͍͍͠ͷʁ •Typeʹ fetch xhr ͕ଟ͍ •ࣗ͝ͷPython Web Application
Λ͝ཡʹͳͬͯΈ͍ͯͩ͘͞ɻ •ϒϥβͷσόοΨΛ։͍ͯϦϩʔυ •Protocol=HTTP/1.1ʹͳ͍ͬͯΔʢLBͷଆ͕HTTP/1.1ͷՄೳੑʣ → ͕վળͷՄೳੑ
쎕썿쎘 •HTTP/2Կ͕͓͍͍͠ͷʁ •Typeʹ fetch xhr ͕ଟ͍ •ࣗ͝ͷPython Web Application
Λ͝ཡʹͳͬͯΈ͍ͯͩ͘͞ɻ •ϒϥβͷσόοΨΛ։͍ͯϦϩʔυ •Protocol=HTTP/1.1ʹͳ͍ͬͯΔʢLBͷଆ͕HTTP/1.1ͷՄೳੑʣ
쎕썿쎘 •HTTP/2Կ͕͓͍͍͠ͷʁ •HTTP/2ͷWebserver Hypercorn ʹ͢Δ͜ͱͰվળ͕ΈΒΕΔ •Typeʹ fetch xhr ͕ଟ͍
•ࣗ͝ͷPython Web Application Λ͝ཡʹͳͬͯΈ͍ͯͩ͘͞ɻ •ϒϥβͷσόοΨΛ։͍ͯϦϩʔυ •Protocol=HTTP/1.1ʹͳ͍ͬͯΔʢLBͷଆ͕HTTP/1.1ͷՄೳੑʣ → ͕վળͷՄೳੑ
쎕썿쎘 •HTTP/2Կ͕͓͍͍͠ͷʁ •Typeʹ fetch xhr ͕ଟ͍ •ࣗ͝ͷPython Web Application
Λ͝ཡʹͳͬͯΈ͍ͯͩ͘͞ɻ •ϒϥβͷσόοΨΛ։͍ͯϦϩʔυ •Protocol=HTTP/1.1ʹͳ͍ͬͯΔʢLBͷଆ͕HTTP/1.1ͷՄೳੑʣ ͔͠Ε·ͤΜ •HTTP/2ͷWebserver Hypercorn ʹ͢Δ͜ͱͰվળ͕ΈΒΕΔ → ͕վળͷՄೳੑ
썡쎕써 •AWSͰσϓϩΠ͍ͯ͠Δ߹ •ALB ʹ ଆHTTP/2 ະରԠͷͨΊɺHTTP/̍.1 ϒϥβ ALB Web Server
Web FW )551 )551 84(*"4(*
썡쎕써 •AWSͰσϓϩΠ͍ͯ͠Δ߹ •ALB ʹ ଆHTTP/2 ະରԠͷͨΊɺHTTP/̍.1 •NLB ʹ 20206݄ʹଆHTTP/2ରԠ͍ͯ͠Δ ϒϥβ
Ϧόʔε ϓϩΩγ Hyper corn Web FW )551 )551 "4(* IUUQTBXTBNB[PODPNKQBCPVUBXTXIBUTOFXOFUXPSLMPBECBMBODFSOPXTVQQPSUTUMTBMQOQPMJDJFT
썡쎕써̎ •WSGIΞϓϦέʔγϣϯͷ߹ •HypercornʢASGI WebαʔόWSGIରԠ͍ͯ͠·͢ʣͰσϓϩΠՄೳ •ࢼͯ͠ΈΔՁ͕͋Δ͔ʂʁ •Django 2ܥ - wsgi.pyΛϥοϓ͢Δ͚ͩ from
hypercorn.middleware import AsyncioWSGIMiddleware import sampleproject.wsgi as wsgi_app asyncio_app = AsyncioWSGIMiddleware(wsgi_app.application) https://github.com/jrfk/django2-hypercorn
쏑쏡쏷쎮쎅બࢶ썿썮썽 •GunicornˎWSGIϑϨʔϜϫʔΫ •GunicornˎWSGIϑϨʔϜϫʔΫˎmeinheld •seroryˎGunicornˎWSGIϑϨʔϜϫʔΫ •UvicornˎASGIϑϨʔϜϫʔΫ
쏑쏡쏷쎮쎅બࢶ썿썮썽 •GunicornˎWSGIϑϨʔϜϫʔΫ •GunicornˎWSGIϑϨʔϜϫʔΫˎmeinheld •seroryˎGunicornˎWSGIϑϨʔϜϫʔΫ •UvicornˎASGIϑϨʔϜϫʔΫ •HypercornˎASGIϑϨʔϜϫʔΫ/WSGIϑϨʔϜϫʔΫ
쏑쏡쏷쎮쎅બࢶ썿썮썽 •GunicornˎWSGIϑϨʔϜϫʔΫ •GunicornˎWSGIϑϨʔϜϫʔΫˎmeinheld •seroryˎGunicornˎWSGIϑϨʔϜϫʔΫ •UvicornˎASGIϑϨʔϜϫʔΫ •HypercornˎASGIϑϨʔϜϫʔΫ/WSGIϑϨʔϜϫʔΫ
ࢀߟࢿྉ •How to serve HTTP/2 using Python IUUQTNFEJVNDPNQZUIPOQBOEFNPOJVNIPXUPTFSWFIUUQVTJOHQZUIPOFCCEF⒎ •HTTP/1 should
die IUUQTNFEJVNDPN!QHKPOFTIUUQTIPVMEEJFCEF •Hypercorn IUUQTQHKPOFTHJUMBCJPIZQFSDPSOJOEFYIUNM •jrfk / fastapi-hypercorn_Performance-measurement IUUQTHJUIVCDPNKSGLGBTUBQJIZQFSDPSO@1FSGPSNBODFNFBTVSFNFOU