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
180
Event-Driven asyncio: A Case Study of Trio's API(PyCon US 2024)
jrfk
1
150
EuroPython 2023体験記 - 非英語話者の海外登壇@みんなのPython勉強会#98
jrfk
0
200
Asyncio Evolved: Enhanced Exception Handling with TaskGroup in Python 3.11(PyConTW 2023)
jrfk
0
43
Asyncio Evolved: Enhanced Exception Handling with TaskGroup in Python 3.11(EuroPython 2023)
jrfk
3
1.3k
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
810
Other Decks in Programming
See All in Programming
なまけものオバケたち -PHP 8.4 に入った新機能の紹介-
tanakahisateru
1
120
情報漏洩させないための設計
kubotak
1
140
短期間での新規プロダクト開発における「コスパの良い」Goのテスト戦略」 / kamakura.go
n3xem
2
170
数十万行のプロジェクトを Scala 2から3に完全移行した
xuwei_k
0
270
Monixと常駐プログラムの勘どころ / Scalaわいわい勉強会 #4
stoneream
0
280
創造的活動から切り拓く新たなキャリア 好きから始めてみる夜勤オペレーターからSREへの転身
yjszk
1
130
Keeping it Ruby: Why Your Product Needs a Ruby SDK - RubyWorld 2024
envek
0
190
Fibonacci Function Gallery - Part 1
philipschwarz
PRO
0
220
「とりあえず動く」コードはよい、「読みやすい」コードはもっとよい / Code that 'just works' is good, but code that is 'readable' is even better.
mkmk884
3
290
ブラウザ単体でmp4書き出すまで - muddy-web - 2024-12
yue4u
3
470
선언형 UI에서의 상태관리
l2hyunwoo
0
160
20年もののレガシープロダクトに 0からPHPStanを入れるまで / phpcon2024
hirobe1999
0
470
Featured
See All Featured
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
6.9k
Typedesign – Prime Four
hannesfritz
40
2.4k
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.3k
How to Think Like a Performance Engineer
csswizardry
22
1.2k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
45
2.2k
A Tale of Four Properties
chriscoyier
157
23k
Why Our Code Smells
bkeepers
PRO
335
57k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
127
18k
Speed Design
sergeychernyshev
25
670
How STYLIGHT went responsive
nonsquared
95
5.2k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5.1k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
2
290
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