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
Erlang/OTP で作るリアルタイムサーバー
Search
yamionp
June 01, 2019
Technology
6
3.8k
Erlang/OTP で作るリアルタイムサーバー
Erlang & Elixir Fest 2019 で発表した「 Erlang/OTP で作るリアルタイムサーバー」 の資料になります.
yamionp
June 01, 2019
Tweet
Share
Other Decks in Technology
See All in Technology
alecthomas/kong はいいぞ / kamakura.go#7
fujiwara3
1
300
TSKaigi 2024 の登壇から広がったコミュニティ活動について
tsukuha
0
160
Amazon VPC Lattice 最新アップデート紹介 - PrivateLink も似たようなアップデートあったけど違いとは
bigmuramura
0
190
バクラクのドキュメント解析技術と実データにおける課題 / layerx-ccc-winter-2024
shimacos
2
1.1k
社外コミュニティで学び社内に活かす共に学ぶプロジェクトの実践/backlogworld2024
nishiuma
0
260
【re:Invent 2024 アプデ】 Prompt Routing の紹介
champ
0
140
KnowledgeBaseDocuments APIでベクトルインデックス管理を自動化する
iidaxs
1
260
[Ruby] Develop a Morse Code Learning Gem & Beep from Strings
oguressive
1
160
非機能品質を作り込むための実践アーキテクチャ
knih
5
1.3k
サービスでLLMを採用したばっかりに振り回され続けたこの一年のあれやこれや
segavvy
2
410
PHP ユーザのための OpenTelemetry 入門 / phpcon2024-opentelemetry
shin1x1
1
200
日本版とグローバル版のモバイルアプリ統合の開発の裏側と今後の展望
miichan
1
130
Featured
See All Featured
Scaling GitHub
holman
458
140k
GitHub's CSS Performance
jonrohan
1030
460k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
365
25k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
127
18k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
28
900
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
59k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
26
1.9k
Become a Pro
speakerdeck
PRO
26
5k
YesSQL, Process and Tooling at Scale
rocio
169
14k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
169
50k
Making the Leap to Tech Lead
cromwellryan
133
9k
Transcript
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE ϦΞϧλΠϜαʔόʔ ERLANG/OTP Ͱ࡞Δ 1 ݄ HVNJ*ODਗ਼ਫ༎ޗ ERLANG
& ELIXIR FEST 2019
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 2 ձࣾհ
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 3 ձࣾհ ઃཱ ݄ ࠃࢠձࣾ ւ֎ࢠձࣾ ࣄۀ༰
ϞόΠϧήʔϜࣄۀ ࣾ ࣾ 93ࣄۀ 73 "3 .3ͳͲ ࣾ ࣾ ϒϩοΫνΣʔϯࣄۀ ࣾ ઃཱ ݄ ࠃࢠձࣾ ւ֎ࢠձࣾ ࣄۀ༰ ϞόΠϧήʔϜࣄۀ ࣾ ࣾ 93ࣄۀ 73 "3 .3ͳͲ ࣾ ࣾ ϒϩοΫνΣʔϯࣄۀ ࣾ ˞݄ݱࡏ ࣄۀྫϞόΠϧήʔϜࣄۀͷ໊ࣗࣾٛ৴ͷҰ෦ ͳͲʜ
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE ࣗݾհ ▸ ਗ਼ਫ༎ޗ!ZBNJPOQ ▸ 2011 ೖࣾ ▸
2015 R&D 4 ήʔϜαʔόʔͷ։ൃ ڞ௨ج൫ͷ։ൃ ϦΞϧλΠϜαʔόʔͷ։ൃ ڞ௨ج൫։ൃɾӡ༻νʔϜϚωʔδϟʔ ࣍ੈڞ௨ج൫ͷ։ൃ
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 5 ࠓ͢ࣄ ϦΞϧλΠϜαʔόʔ Λ Erlang/OTP Ͱ ϓϩτίϧ͔Β
࡞ͬͨ
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 6 ࠓ͢ࣄ ϦΞϧλΠϜ αʔόʔͱ
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 7 1 VS 1 ͷϚϧνରઓ
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE ήʔϜͷ தͰ 8
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 9 1 VS 1 ͷϚϧνରઓ ΩϟϥΫλʔ2ମ?
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 10 1 VS 1 ͷϚϧνରઓ ίϯϐϡʔλʔ2͋Δ
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 11 1 VS 1 ͷϚϧνରઓ ίϯϐϡʔλʔ2͋Δ COPY
COPY ΩϟϥΫλʔ4ମ ௨৴ ௨৴
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE ೋͷίϯϐϡʔλʔͰ௨৴͢Δඞཁ͕͋Δ ▸ ࣗͷΩϟϥΛಈ͔ͨ͠Β͙͢ʹ$01:ʹΘͬͯཉ͍͠ ▸ ૬खͷ$01:ʹμϝʔδΛ༩͑ͨΒ͙͢ʹΦϦδφϧʹΘͬͯཉ͍͠ ▸ ߴස௨৴
▸ εϚϗͦͷ··Ͱ௨৴͕͍͜͠ͱ͕ଟ͍ 12
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 13 ϦΞϧλΠϜαʔόʔͱ 1VC4VC 2 VS 2 ͷରઓήʔϜ
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE ήʔϜҎ֎ʹ 14
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 15 ͓ख͍ͷ࣮ྫ ϚΠΫϩαʔϏε܈ 0DVMVT4UPSF 'BDFCPPL ʜ "1*
ೝূ ՝ۚ ৴ 6OJUZ IUUQTWBSLDPKQ ϓϥοτϑΥʔϜ܈ 1SPYZ 1VC4VC ৴ελδΦ ήʔϜαʔό
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 16 ΞδΣϯμ ͳͥϦΞϧλΠϜαʔόʔ͔ ઃܭ Pub/SubϞσϧ ϓϩτίϧ
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 17 ΞδΣϯμ ͳͥϦΞϧλΠϜαʔόʔ͔ ઃܭ Pub/SubϞσϧ ϓϩτίϧ
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE ͜Ε·ͰͷιʔγϟϧήʔϜ ▸ ඇಉظίϛϡχέʔγϣϯ ▸ ಉ࣌ʹ༡ΜͰ͍ͳ͍ͷʹҰॹʹ༡ΜͰ͍Δײ֮ ▸ χίχίಈը
▸ ٕज़త੍ ▸ ϞόΠϧ8FCಛ༗ͷ༷ ▸ ॲཧೳྗɾόοςϦʔ ▸ ճઢɾྉۚʢύέࢮʣ 18
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE ΧδϡΞϧήʔϜ͔ΒΑΓೱີͳήʔϜମݧ ▸ ΑΓڧ͍࿈ܞɾҰମײ ▸ ຊͷಉ࣌ϓϨΠ ▸ χίχίੜ์ૹ
▸ ΞϓϦԽ ▸ ੑೳɾωοτϫʔΫڥͷܶతͳ্ 19
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 20 ϦΫΤετ/Ϩεϙϯε Ϟσϧ 1. Request 2. Response
Client Server ࠓ͍ͬͯΔ)551௨৴
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 21 ϦΫΤετ/Ϩεϙϯε Ϟσϧ Client Server 1.Request αʔόʔͰى͖ͨ͜ͱΛ
ࠓ͙͢ʹ͑ΒΕͳ͍
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE Կ͕͔ʁ ▸ ௨৴Ϣʔβʔଆ͔Β͔͠։࢝Ͱ͖ͳ͍ʢ4FSWFS͔Β։࢝Ͱ͖ͳ͍ʣ ▸ ߴසͷ௨৴͕͍͠ʢຖඵճ௨৴͍ͨ͠ʣ ▸ Φʔόʔϔου
▸ ϨΠϯςϯγ 22
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE Server Client SYN SYN+ACK ACK ࠷ॳʹ Connection
Λཱ֬͢Δ 23 TCP CONNECTION Λ͏
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE Server Client Connection ͕͋ΔݶΓࣗ༝ͳλΠϛϯάͰ௨৴Ͱ͖Δ 24 TCP CONNECTION
Λ͏
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 25 HTTPͰTCP͍ͬͯΔ͕ Response Λฦͨ͠Β Connection Λഁغ͢Δ ʢεςʔτϨεʣ
Server Client
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE ϦΞϧλΠϜ௨৴ͷϝϦοτ ▸ ४උ͑͞Ͱ͖Ε ͲͪΒ͔ΒͰૹΓ࢝ΊΒΕΔ ▸ Ұճ͋ͨΓͷ௨৴ίετ͕খ͍͞ ▸
ඵؒճͱ͔ૹΔ͜ͱ͕Ͱ͖Δ ▸ Ԇ͕গͳ͍ 26
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE ϦΞϧλΠϜ௨৴ͷσϝϦοτ ▸ ෛՙ͕ߴ͍ɾෛՙࢄ͠ʹ͍͘ ▸ ঢ়ଶΛϝϞϦ্ʹ࣋ͭͷͰোʹऑ͍ ▸ Τϥʔύλʔϯ͕ଟ͘ίʔυ͕ෳࡶʹͳΓ͕ͪ
▸ ͷόοςϦʔফඅ͕ܹ͍͠ ௨৴සʹґଘ 27
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE ؒͷ௨৴ 11 ʁ ▸ ಠྗͰͭͳ͕Δͷ͍͠ ▸ ఆ͞ΕΔ΄΅શͯͷ/"5ͷԼʹ͋Δ
▸ 8J'JڥؚΊΔͱɺͲΕ͚ͩؤுͬͯܨ͕Βͳ͍͕͋Δ ▸ ͕૿͑ͨ࣌ͷશମͷ௨৴ྔ͕രൃ͢Δ ▸ αʔόʔαΠυϩδοΫ͕͋Δ߹ʹθϩ͔Β։ൃ͕ඞཁ 28
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 29 ϑϧϝογϡ
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 30 ϑϧϝογϡ
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 31 ελʔ
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 32 ελʔ
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE ͳͥطଘͷͷ࠾༻Ͱͳ͔͔ͬͨ ▸ 8JOEPXT4FSWFS զʑʹͱͬͯ ӡ༻ίετ͕ߴ͍ ▸ ػೳաଟ
▸ ήʔϜͰͷ௨৴ʹಛ༗ͳ༷ͷରԠ ▸ མͱͨ͘͠ͳ͍ɻʹ৸͍ͯΒΕΔγεςϜ͕ཉ͔ͬͨ͠ ▸ طଘγεςϜͱͷ૬ੑ 33
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 34 طଘͷΈͱ՞͠ͳ͍γϯϓϧͳγεςϜ͕ཉ͍͠ ELB App Job MQ Batch
log 1VC4VC
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 35 ΞδΣϯμ ϦΞϧλΠϜαʔόʔͱ Pub/SubϞσϧ ϓϩτίϧ ઃܭ
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE ίϯηϓτ ▸ ͱͯ͠ͷׂʹప͢Δ ▸ εςʔτϑϧɺσʔλϨε ▸ ࣭ॏࢹ
▸ ҆ఆͯ͠ܨ͕Γɺͦͦ͘͜͜ɺམͪͳ͍ɻ ▸ 5$1ϝΠϯ 36
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE ʹప͢Δ ▸ ίωΫγϣϯΛ࣋ͭʹঢ়ଶ͕ଟ͘ͳΔ ▸ ωοτϫʔΫϓϩάϥϛϯάͷେΤϥʔϋϯυϦϯά ▸ ͖࣋ͭঢ়ଶۃྗݮΒ͢
▸ ΞοϓσʔτͷՄೳੑΛݮΒ͢ ▸ அʹͭͳ͕Δ 37
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE εςʔτϑϧɾσʔλϨε ▸ ঢ়ଶʢεςʔτʣ͕࣋ͭɺσʔλ࣋ͨͳ͍ɻ ▸ ӬଓԽ͠ͳ͍ ▸ ඞཁͳσʔλ֎෦ʹ͍߹ΘͤPS௨
FYೝূ ▸ ىಈͨ͠Β͙͑͢Δঢ়ଶ 38
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 39 ೝূ App 1. game start API
2. IP:Port, Token, Topic 3. Connect Token 4. Token 5. OK 6. OK 1VC4VC
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE ࣭ॏࢹ ▸ υΩϡϝϯτ ▸ ҉ͷϧʔϧΛ࡞Βͳ͍ ▸ 4QIJOYΛ࠾༻
QBDLFUEJBH ▸ ෛՙࢼݧ ▸ ੑೳΛอূ͢Δ 40 ▸ ࣗಈςετ ▸ σάϨͤ͞ͳ͍ ▸ &OEUP&OEςετʹͩ͜ΘΔ ▸ λΠϜΞτ ▸ ಉ࣌ॲཧ
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE ͳͥTCP͔ʁ ▸ /"5͑ ▸ ౸ୡอূ ▸ ॱংอূ
▸ ੍ޚ ▸ ήʔϜʹΑͬͯ5$1ͷΈͰेͳ߹ଟ͍ λʔϯ੍ͳͲ 41
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE UDP ▸ ͋͘·Ͱ5$1ͷαϒͱͯ͠ͷ6%1 ▸ ౸ୡอূͳ͠ɾॱংอূͳ͠ɾ੍ޚͳ͠ ▸ ࣭ͷྑ͘ͳ͍ճઢͳͲͰͱʹ͔͘ૣ͘ૹΓ͍ͨ߹
▸ ॏཁͳΓͱΓ5$1Ͱߦ͏ 42
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE ͳͥ ERLANG/OTP ͳͷ͔ ▸ ಈతܕ͚ ▸ ༏Εͨোੑ
▸ ฒߦॲཧɾࢄॲཧʹڧ͍ 43
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE ܰྔϓϩηε ▸ ىಈɾ༻ϝϞϦ͕ܰྔͳϓϩηε ▸ 04ͷϓϩηεɾεϨουͱҧ͏ ▸ ҰॠͰ্ཱ͕ͪΓɺ͘͝Θ͔ͣͳϝϞϦ͔͠༻͠ͳ͍
▸ ΠϯελϯεΛ࡞Δײ֮ͰϓϩηεΛ࡞Δ ▸ ສɺेສͷϓϩηεΔ ▸ ϓϩηεؒͰϝοηʔδ௨৴͕Ͱ͖Δ 44
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE CRASHͯ͠ྡͷϓϩηεʹӨڹ͕ͳ͍ ▸ Τϥʔ͕ىͬͨ͜ϓϩηεࢮ͵ ▸ ϓϩηε͕ࢮΜͩࣄࢹ͍ͯ͠Δผͷϓϩηεʹରॲͤ͞Δ ▸ ࠶ىಈޙ࢝Λͨ͠Γɺ࿈ܞ͢Δ΄͔ͷϓϩηεͷॲஔΛͨ͠Γ
▸ Ϋϥελͷ߹ɺࢹϓϩηεผͷϚγϯͰಈ͍͍ͯͯͳ͍ ▸ ਖ਼ৗܥͱҟৗܥͷॲཧ͕͞ΕΔ 45
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE ࣾʹಋೖ࣮͕͋ͬͨ ▸ ೝূɾ՝ۚɾςΩετݕূɺͦΕͧΕͷϚΠΫϩαʔϏε ▸ ؒͷ࿈ଓՔಇ࣮ ▸ શΞϓϦ͔ΒͷϦΫΤετΛͰॲཧ͍ͯ͠Δ
46
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE ARK ArkPubSub Server 47 ໋໊
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 48 ΞδΣϯμ ࣮ Pub/SubϞσϧ ͳͥϦΞϧλΠϜαʔόʔ͔ ઃܭ
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE PUB/SUB(ग़൛/ߪಡ)Ϟσϧͱ ▸ ඇಉظϝοηʔδϯάϞσϧͷҰछ ▸ 4VCTDSJCF ߪಡ ͍ͯ͠ΔϢʔβʔʹϝοηʔδΛ1VCMJTI
ग़൛ ͢Δ ▸ 4VCଆ5PQJDͱ͍͏୯ҐͰߪಡ͢Δ ▸ 1VCଆ5PQJDʹϝοηʔδΛૹΔ ▸ 1VCଆ4VCଆΛҙࣝ͢Δඞཁ͕ͳ͘ɺૄ݁߹ʹͳΔ 49
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 50 /CHATROOM/AAA A B C D PubSub
Subscribe
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 51 /CHATROOM/AAA A B C D PubSub
Publish
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 52 /CHATROOM/AAA /TOPIC/BBB A B C D
PubSub Subscribe
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 53 A B C D PubSub Publish
/CHATROOM/AAA /TOPIC/BBB
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE ROOM Ϟσϧͱͷҧ͍ ▸ 4VCTDSJCFS͕ͷ5PQJDʹ1VCMJTIͰ͖Δ ▸ 1VCMJTIFS͕5PQJDΛ4VCTDSJCF͍ͯ͠Δඞཁͳ͍ ▸
3PPNͷཧ ࡞আ ͕ඞཁͳ͍ 54
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE ࣮ࡍͷήʔϜͰͷΘΕํ Room/1234 A B C PubSub શһͷϝοηʔδશһ༻ͷ
Topic
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE ࣮ࡍͷήʔϜͰͷΘΕํ Room/1234 Room/1234/User/A A B C PubSub
Room/1234/User/B Room/1234/User/C ݸਓͷϝοηʔδݸਓ༻ͷ Topic
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE ࣮ࡍͷήʔϜͰͷΘΕํ Room/1234 Room/1234/User/A A B C PubSub
Room/1234/User/B Room/1234/User/C ࢀՃऀ શମ༻ Topic ͱ ݸਓ༻ Topic Λ Subscribe ͢Δ Room/1234/User/D D
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE ࣮ ▸ HQSPDΛར༻ ▸ 5PQJDͷ࣮ମ&54ʹ֨ೲ͞ΕͨTVCTDSJCF͍ͯ͠ΔϓϩηεͷҰཡ ▸ 4VCTDSJCF͢Δͱ4FTTJPO͕5PQJDΛΩʔʹࣗͷ1*%Λॻ͖ࠐΉ
▸ 1VCMJTIଆ1VCMJTIઌ5PQJDͰ&54͔Β1*%ͷҰཡΛऔಘ ▸ ҰཡʹΉ͚ͯϝοηʔδૹ৴Λߦ͏ 58
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 59 SUBSCRIBEͷ࣮ ranch ErlangVM
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 60 SUBSCRIBEͷ࣮ ranch ErlangVM session <0.99.0>
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 61 SUBSCRIBEͷ࣮ ranch ErlangVM session <0.99.0> Topic/AA
<0.80.0> ETS
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 62 SUBSCRIBEͷ࣮ ranch session <0.99.0> ErlangVM Write
<0.99.0> Topic/AA <0.80.0> ETS
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 63 SUBSCRIBEͷ࣮ ranch ErlangVM Topic/AA <0.80.0>, <0.99.0>
session <0.99.0> ETS
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE ྃ! 64
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 65 PUBLISHͷ࣮ ranch session <0.99.0> ErlangVM link
Topic/AA <0.80.0>, <0.99.0> Read session <0.80.0> Send ETS
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE ྃ! 66
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 67 ΞδΣϯμ ࣮ ͳͥϦΞϧλΠϜαʔόʔ͔ ઃܭ Pub/SubϞσϧ
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 68 ϓϩηεσβΠϯ ranch session (system process) session_udp
ErlangVM link link
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 69 ϓϩηεσβΠϯ ranch sessions_sup (simple_one_for_one) arkps_sup (one_for_one)
session_udp_sup (simple_one_for_one) ErlangVM udp_sup (one_for_one) gen_udp session (system process) session_udp link link
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 70 ϓϩηεσβΠϯ ranch session (system process) session_udp
sessions_sup (simple_one_for_one) arkps_sup (one_for_one) session_udp_sup (simple_one_for_one) ErlangVM udp_sup (one_for_one) gen_udp link link
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE ϓϩτίϧํ ▸ CJUΛΓ٧ΊΔΑΓγϯϓϧͰ͋Δ͜ͱ ▸ ඞཁेͳ֦ுੑ ▸ γϦΞϥΠζɾύʔε͕͍͢͠
▸ &SMBOHόΠφϦʹڧ͍ͷͰҙ͢Δ 71
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE ϓϩτίϧ֓ཁ ▸ 5$1Λ࠾༻ ▸ 5-7ϕʔεͷϓϩτίϧߏ ▸ ࠷খݶͷݻఆϔομͱ֦ு෦ͷ5-7Խ
▸ CZUFT୯Ґ 72
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 73 ݻఆϔομ 1 bit 16 32 Type
(ϝοηʔδͷछྨ) Length (શମͷ͞) SenderTimestamp (ૹ৴ऀ࣌ؒ) ※ޙड़ ReceiverTimesamp (ड৴ऀ࣌ؒ) ※ޙड़ Payload (ૹ৴༰)
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 74 PAYLOAD ࿈ଓͨ͠ TLV ͷܗΛͱΔ 1 16
32 SectionType SectionLength Value
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE ͭ·Γ 75
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 76 TLVϕʔε 1 16 32 Type Length
SenderTimestamp ReceiverTimesamp SectionType SectionLength Value SectionType SectionLength Value
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE ͜ͷߏʹΑΔϝϦοτ ▸ ֦ு͍͢͠ ▸ ࣮͕ൺֱత༰қ ▸ όϦσʔγϣϯ͕༰қ
77
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE RTTܭଌ ▸ Ϣʔβʔαʔόʔͷճઢঢ়ଶΛѲ͍͍ͯͨ͠ ▸ ڧ੍அͳͲ ▸ ௨৴࣌ʹࣗͷλΠϚʔͱॲཧ࣌ؒΛՃࢉͨ͠૬खͷλΠϚʔΛૹΔ
78
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 79 ݻఆϔομ 1 bit 16 32 Type
(ϝοηʔδͷछྨ) Length (શମͷ͞) SenderTimestamp (ૹ৴ऀ࣌ؒ) ※ޙड़ ReceiverTimesamp (ड৴ऀ࣌ؒ) ※ޙड़ Payload (ૹ৴༰)
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 80 RTTܭଌ Client Timer Timer 1ms 1000ms
Sender 1 ड৴͔Βૹ৴·Ͱʹ NT͔͔ͬͨͷͰ ड͚औͬͨʹΛ͢ Receiver 301 1300ms 321ms ͜ͷ࣌ͰࣗͷλΠϚʔ͕ ͳͷͰΛҾ͍ͯ355NT PubSub 300ms
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 81 RTTܭଌ Client Timer Timer 1 1000
Sender Receiver 1 0 ※ ˞ॳճ૬खͷ5JNFS͕ Θ͔Βͳ͍ͷͰ ૹ৴·ͰʹNT͔͔ͬͨͷͰ ड͚औͬͨʹΛ͢ Sender Receiver 1300 301 1300 321 ͜ͷ࣌ͰࣗͷλΠϚʔ͕ ͳͷͰ355NT 421 ૹ৴·ͰʹNT͔͔ͬͨͷͰ ड͚औͬͨʹΛ͢ Sender Receiver 421 1400 1420 ͜ͷ࣌ͰࣗͷλΠϚʔ͕ ͳͷͰ355NT 521 1520 ͜ͷ࣌ͰࣗͷλΠϚʔ͕ ͳͷͰ355NT Sender Receiver 521 1500 ड৴͔Βૹ৴·ͰʹNT͔͔ͬͨͷͰ ड͚औͬͨʹΛ͢ PubSub
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE ෛՙࢼݧ 82
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE ͳͥෛՙࢼݧΛߦ͏͔ ▸ ݶքੑೳΛΔ ▸ ϘτϧωοΫͷൃݟ ▸ εέʔϧ͢Δ͜ͱͷ֬ೝ
▸ ඞཁ༰ྔͷܭࢉ ▸ ίετࢼࢉ 83
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE LOCUSTΛ࠾༻ ▸ 1ZUIPOࢄෛՙࢼݧπʔϧ ▸ ͜ͷͨΊʹϑϧػೳͷ1ZUIPOΫϥΠΞϯτΛ։ൃ ▸ ଓଆͲΜͳʹؤுͬͯݶք͕͘ΔͷͰͰղܾ
▸ εϙοτΠϯελϯε͍҆ ▸ NMBSHFͷεϙοτΠϯελϯε͕UNFEJVNΦϯσϚϯυΑΓ͔҆ͬͨ 84
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 85 Locust Slaves x8 Locust Master m4.2xlarge
CPU: 8 RAM: 32GB m4.xlarge CPU: 4 RAM: 16GB PubSub
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 86 ϝοηʔδܭଌ ਓ෦Ͱճ৴͢Δͱ ৴໋ྩϝοηʔδ ֤ϝοηʔδ ߹ܭϝοηʔδ PubSub
શһ͕1ඵʹ1ճ৴͢Δͱ 8ਓ x 8ϝοηʔδ = ຖඵ64ϝοηʔδ
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 87 user/room 8 message/user/sec 0.2 waittime[ms]5000 rooms
100 1000 2000 3000 3500 3750 (ఆ) users 800 8000 16000 24000 28000 30000 (ఆ) message/sec 1280 12800 25600 38400 44800 48000 (࣮ଌ) message/sec 1270 12783 25560 38328 44787 21054 (Server)CPU [%] 66.5 360.4 404.7 560.9 635.8 444.4 (Server)RAM [%] 0.6 2.4 3.7 6.2 7.2 16.5 RTT Med [ms] 1 2 5 12 19 34 RTT Avg [ms] 14 11 12 14 27 1260 RTT Max [ms] 44 49 75 356 536 62798 End to End Med [ms] 1 3 8 18 39 460 End to End Avg [ms] 2 12 13 21 50 3017 End to End Max [ms] 747 738 754 1003 1315 100979 66.5 360.4 404.7 560.9 635.8 444.4 1270 12783 25560 38328 44787 21054 0 100 200 300 400 500 600 700 800 0 10000 20000 30000 40000 50000 60000 70000 80000 800 8000 16000 24000 28000 30000 8user/room 1msg/5s (Server)CPU [%] () message/sec
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 88 user/room 8 message/user/sec 1 waittime[ms]1000 rooms
100 400 800 900 1000 (ఆ) users 800 3200 6400 7200 8000 (ఆ) message/sec 6400 25600 51200 57600 64000 (࣮ଌ) message/sec 6360 25527 48195 53240 25154 (Server)CPU [%] 275.8 618.3 709.3 774.7 766.7 (Server)RAM [%] 0.5 1.1 2.7 3 11.2 RTT Med [ms] 1 1 5 12 5 RTT Avg [ms] 10 7 24 40 494 RTT Max [ms] 45 48 491 1100 34295 End to End Med [ms] 2 11 36 80 310 End to End Avg [ms] 10 13 54 120 970 End to End Max [ms] 554 550 981 2923 44120 275.8 618.3 709.3 774.7 766.7 6360 25527 48195 53240 25154 0 100 200 300 400 500 600 700 800 0 10000 20000 30000 40000 50000 60000 70000 80000 800 3200 6400 7200 8000 8user/room 1msg/s (Server)CPU [%] () message/sec
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 89 user/room 8 message/user/sec 15 waittime[ms] 66.6666666666667
rooms 10 50 70 80 90 100 (ఆ) users 80 400 560 640 720 800 (ఆ) message/sec 9600 48000 67200 76800 86400 96000 (࣮ଌ) message/sec 9096 46047 58600 60764 63539 26390 (Server)CPU [%] 229.8 694.7 776.6 775.6 787.9 786.2 (Server)RAM [%] 0.4 0.5 0.6 0.7 0.7 8 RTT Med [ms] 38 2 7 10 15 24 RTT Avg [ms] 30 14 15 17 23 194 RTT Max [ms] 45 67 93 122 522 20686 End to End Med [ms] 19 19 24 33 46 73 End to End Avg [ms] 18 21 27 37 50 293 End to End Max [ms] 618 631 657 718 1231 39470 229.8 694.7 776.6 775.6 787.9 786.2 9096 46047 58600 60764 63539 26390 0 100 200 300 400 500 600 700 800 0 10000 20000 30000 40000 50000 60000 70000 80000 80 400 560 640 720 800 8user/room 15msg/s (Server)CPU [%] () message/sec
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE TCP Ͱͷੑೳ 5 ສ MESSAGE / SEC
90
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE UDPͷεϧʔϓοτ͕TCPͷ1/5 ▸ αϒػೳͱͯ͠6%1Ͱͷૹ৴ػೳΛ͚ͭͯࢼݧΛ͕ͨ͠ສTͰͳ͍ ▸ 7ʮສT͍͚Δʯ 91
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE FPROF ͰϓϩϑΝΠϦϯά ▸ TFOE͕͍ ▸ QPSU@DPNNBOEͰඇಉظʹͨ͠Βղܾ ▸
HFO@VEQUDQTFOE͕ϘτϧωοΫͳͱ͖ʹΔ͜ͱ IUUQRJJUBDPNNVSVSVJUFNTCFCCBDFC 92
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 93 user/room 8 message/user/sec 0.2 waittime[ms]5000 rooms
100 2000 3750 6250 7500 8750 (ఆ) users 800 16000 30000 50000 60000 70000 (ఆ) message/sec 1280 25600 48000 80000 96000 112000 (࣮ଌ) message/sec 1281 25639 48124 78742 94555 97731 (Server)CPU [%] 46.9 312.2 426.8 625 723.2 718 (Server)RAM [%] 2 6.8 9.8 14 17.3 18.7 1281 25639 48124 78742 94555 97731 0 100 200 300 400 500 600 700 800 0 20000 40000 60000 80000 100000 120000 140000 160000 800 16000 30000 50000 60000 70000 8user/room 1msg/5s (Server)CPU [%] () message/sec
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 94 user/room 8 message/user/sec 1 waittime[ms]1000 rooms
100 400 800 1000 1200 1400 1600 (ఆ) users 800 3200 6400 8000 9600 11200 12800 (ఆ) message/sec 6400 25600 51200 64000 76800 89600 102400 (࣮ଌ) message/sec 6356 25472 51202 63890 75912 88143 99033 (Server)CPU [%] 139.4 269.1 425 500.3 625.8 699.2 765.3 (Server)RAM [%] 2 3.6 5 5 5.2 5.2 6.6 6356 25472 51202 63890 75912 88143 99033 0 100 200 300 400 500 600 700 800 0 20000 40000 60000 80000 100000 120000 140000 160000 800 3200 6400 8000 9600 11200 12800 8user/room 1msg/s (Server)CPU [%] () message/sec
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 95 user/room 8 message/user/sec 15 waittime[ms] 66.6666666666667
rooms 10 50 70 80 90 100 110 120 130 140 (ఆ) users 80 400 560 640 720 800 880 960 1040 1120 (ఆ) message/sec 9600 48000 67200 76800 86400 96000 105600 115200 124800 134400 (࣮ଌ) message/sec 8912 45967 64648 74035 83211 91581 99596 106775 112889 116739 (Server)CPU [%] 161.5 374.2 489.7 535.8 582.1 632.1 666.4 703.7 726.9 784.7 (Server)RAM [%] 2.1 2.3 2.3 2.3 2.3 2.2 1.8 2.6 3 3.4 8912 45967 64648 74035 83211 91581 99596 106775 112889 116739 0% 100% 200% 300% 400% 500% 600% 700% 800% 0 20000 40000 60000 80000 100000 120000 140000 10 50 70 80 90 100 110 120 130 140 8user/room 15msg/s (Server)CPU [%] () message/sec
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 10 ສ MESSAGE / SEC Λୡ 96
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE ෛՙࢼݧ ▸ ࠷ۙߦͳͬͨ࠶ࢼݧͰෛՙࢼݧπʔϧ͔Βࣗ࡞ͯ͠ߦ͍·ͨ͠ ▸ ৽ଔͷΤϯδχΞ͕ҰਓͰ୲ ▸ ඵؒສϝοηʔδΛ͚͞ʂ
ϦΞϧλΠϜରઓότϧήʔϜΛࢧ͑Δෛՙࢼݧͷઓʲ%FWFMPQFST#PPTUʳ ▸ IUUQTDPEF[JOFKQBSUJDMFEFUBJM 97
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE HWোͷରԠ 98
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 99 HEART BEAT App PubSub PubSub PubSub
HTTP API A 2019-01-01 00:00:00 alive B 2019-01-01 00:00:00 alive C 2019-01-01 00:00:00 alive -4 sec -4 sec -4 sec ఆظత(5ඵʹ1ճ)ʹAPIαʔόʔͷAPIΛݺͼग़͠ RDBMSʹ࠷ऴݺͼग़࣌͠, εςʔλεΛอଘ
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 100 HEART BEAT App PubSub PubSub PubSub
HTTP API A 2019-01-01 00:00:00 dead B 2019-01-01 01:00:00 alive C 2019-01-01 01:00:00 alive A B C -3604 sec -4 sec -4 sec αʔόʔো
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 101 HEART BEAT App PubSub PubSub PubSub
HTTP API A 2019-01-01 00:00:00 dead B 2019-01-01 01:00:00 alive C 2019-01-01 01:00:00 alive A B C -3604 sec -4 sec -4 sec ௨৴ো
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 102 HEART BEAT App PubSub PubSub PubSub
HTTP API A 2019-01-01 00:00:00 dead B 2019-01-01 01:00:00 alive C 2019-01-01 01:00:00 alive A B C -3604 sec -4 sec -4 sec ௨৴ো͔Β෮چ
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 103 HEART BEAT App PubSub PubSub PubSub
HTTP API A 2019-01-01 00:00:00 dead B 2019-01-01 01:00:00 alive C 2019-01-01 01:00:00 alive A B C -3604 sec -4 sec -4 sec Ұࢮఆͨ͠αʔόʔͷ෮ؼ ઈରʹೝΊͳ͍ ௨৴ো͔Β෮چ
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE લఏ ▸ "SL144FSWFSಉҰαʔόʔʹܨ͕͍ͬͯΔϢʔβʔಉ࢜Ͱ͔͠௨৴Ͱ͖ͳ͍ ▸ ΫϥελϦϯάߟྀ͕ͨ͠ ▸ ෳࡶੑ
▸ Ԇ 104
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 105 ͳͥ෮ؼΛೝΊͳ͍͔ App Connection 1. heartbeat 2.
OK 1VC4VC 1VC4VC Server A Server B RoomA Server A RoomB Server B
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 106 ͳͥ෮ؼΛೝΊͳ͍͔ App Connection 1. heartbeat 2.
OK 1VC4VC 1VC4VC Server A Server B RoomA Server A RoomB Server B
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 107 ͳͥ෮ؼΛೝΊͳ͍͔ App 1. RoomA Server? 1VC4VC
2. Server B IP, Port … 1VC4VC Server A Server B RoomA Server B RoomB Server B Connection
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE ΊͰͨ͠ΊͰͨ͠… 108
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 109 ͳͥ෮ؼΛೝΊͳ͍͔ App Connection 1. heartbeat 2.
OK 1VC4VC 1VC4VC Server A Server B RoomA Server A RoomB Server B
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 110 ͳͥ෮ؼΛೝΊͳ͍͔ App Connection 1. heartbeat 2.
OK 1VC4VC 1VC4VC Server A Server B RoomA Server A RoomB Server B 1. RoomA Server? 2. Server B IP, Port …
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 111 ͳͥ෮ؼΛೝΊͳ͍͔ App Connection 1. heartbeat 2.
OK 1VC4VC 1VC4VC Server A Server B RoomA Server B RoomB Server B 1. RoomA Server? 2. Server B IP, Port … Connection ಉ͡αʔόʔʹ͍Δ͖Ϣʔβʔ͕ ผͷαʔόʔʹ
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE όʔδϣϯΞοϓ ▸ ࠓܨ͍Ͱ͍Δਓ ▸ ΫϥΠΞϯτͷόʔδϣϯYαʔόʔͷόʔδϣϯ ▸ ৽͍͠αʔόʔΛͨͯͯɺ"QQͰͷ৽نଓͷҊઌΛมߋ
▸ طଘͷଓ͕͍ͳ͘ͳͬͨΒམͱͯ͠ऴྃ 112
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE ROOM WORKER ▸ 3PPNใΛήʔϜϩδοΫ·ͰؚΊͯ໘ΛΈΔ ▸ ࠷ॳʹ4VCTDSJCF͢Δ ▸
ϒϩʔΧʔ͔ΒΫϥΠΞϯτѻ͍ 113
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE 114 PubSub App Battle ॏཁͳใHTTP API ϦΞϧλΠϜͷΓऔΓ
Ark
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE ࡞ͬͯΈͯ ▸ ࢥͬͨΑΓ͕ग़ͨ ▸ σάϨͤ͞ͳ͍ࣄͷॏཁ͞ ▸ ӡ༻Λ࠷༏ઌͷ࢟
115
$PQZSJHIU $ HVNJ*OD"MM3JHIUT3FTFSWFE ͋Γ͕ͱ͏ ͍͟͝·ͨ͠ 116