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
The tale of kuiperbelt ...and Perl.
Search
mackee
July 14, 2017
Programming
1
2.4k
The tale of kuiperbelt ...and Perl.
吉祥寺.pm11
mackee
July 14, 2017
Tweet
Share
More Decks by mackee
See All by mackee
perl for shell, awk and sed programmers
mackee
2
1.3k
今更GoのWebフレームワークを作ろうとしているワケ / Why am I trying to create a Go web framework now?
mackee
1
63
マイクロサービス化を利用した Goへの移行事例
mackee
0
100
PerlでつくるフルスクラッチWebAuthn/パスキー認証 / Demonstration of full-scratch WebAuthn/Passkey Authentication written in Perl
mackee
3
3.2k
SRE定例やその辺の取り組みをアプリケーションエンジニア目線で語る / "Observe" about SRE Meeting by Application Engineer
mackee
0
1.8k
TinyGoで使えるORM sqllaの 紹介とTinyGoで使えるようにするための工夫
mackee
0
1.1k
Go向けORM sqllaの紹介と JOINやUNIONを含んだクエリの扱い方
mackee
0
4.4k
デプロイ今昔物語 〜CGIからサーバーレスまで〜 / The deployment technics
mackee
10
12k
E2Eテストから負荷試験シナリオを作ってみた / Why do we make a scenario of load testing from E2E testing scenarios
mackee
3
5.4k
Other Decks in Programming
See All in Programming
ActiveSupport::Notifications supporting instrumentation of Rails apps with OpenTelemetry
ymtdzzz
1
230
C++でシェーダを書く
fadis
6
4.1k
Flutterを言い訳にしない!アプリの使い心地改善テクニック5選🔥
kno3a87
1
170
AI時代におけるSRE、 あるいはエンジニアの生存戦略
pyama86
6
1.1k
初めてDefinitelyTypedにPRを出した話
syumai
0
400
Tauriでネイティブアプリを作りたい
tsucchinoko
0
370
Arm移行タイムアタック
qnighy
0
320
macOS でできる リアルタイム動画像処理
biacco42
9
2.4k
Less waste, more joy, and a lot more green: How Quarkus makes Java better
hollycummins
0
100
Outline View in SwiftUI
1024jp
1
330
Nurturing OpenJDK distribution: Eclipse Temurin Success History and plan
ivargrimstad
0
890
OnlineTestConf: Test Automation Friend or Foe
maaretp
0
110
Featured
See All Featured
Reflections from 52 weeks, 52 projects
jeffersonlam
346
20k
Docker and Python
trallard
40
3.1k
5 minutes of I Can Smell Your CMS
philhawksworth
202
19k
The World Runs on Bad Software
bkeepers
PRO
65
11k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
8
860
The Cult of Friendly URLs
andyhume
78
6k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
109
49k
It's Worth the Effort
3n
183
27k
Thoughts on Productivity
jonyablonski
67
4.3k
Why Our Code Smells
bkeepers
PRO
334
57k
What's in a price? How to price your products and services
michaelherold
243
12k
Ruby is Unlike a Banana
tanoku
97
11k
Transcript
The tale of kuiperbelt …and Perl. ٢ࣉ.pm11 2017-07-13 macopy a.k.a
@mackee_w
Yokohama.pmͷ ΄͏͔Βདྷɾɾɾ
(໘നͳͷͰຊຊʹ) ח͔Βདྷ·ͨ͠
YAPC::Fukuoka 2017 HAKATA
༧ఆͰόʔδϣϯݻఆͨ͠ CPANϞδϡʔϧͱͦͷཧ༝ Έ͍ͨͳΛ͢Δ༧ఆͰͨ͠ ͕ফۃతͰ໘ന͘ແͦ͞͏ͳ ͷͰkuiperbeltͷΛ͠·͢
kuiperbeltͱ github.com/mackee/kuiperbelt
݁ہͳΜͶΜ
WebSocketͱHTTP1.1ͷ ૬ޓมϓϩΩγαʔό
kuiperbeltͷׂ • WebSocketͷίωΫγϣϯͷҡ࣋ • ΞϓϦέʔγϣϯαʔό͕ӬଓతίωΫγϣ ϯΛ࣋ͭ͜ͱͷݞΘΓΛ͢Δ • ӬଓతίωΫγϣϯͷෛՙࢄ • ΑΓݫີʹݴ͑ෛՙࢄͷΈ
kuiperbeltͷ࠾༻ྫ • ࠓͷͱ͜Ζݴ͑Δ͕ͭͳ͍ • ͔ࣾ͠͠Ͱݕ౼ٴͼݕূਐΜͰ͍Δͱͩ ͚ਃ͋͛͠·͢ɻࠓͷͱ͜Ζ͑ͯͦ͏
ͱ͜ΖͰkuiperbeltͬͯGoͩΑͶ
kuiperbelt loves Perl
kuiperbelt loves Perl5(like languages) • kuiperbelt͋͘·ͰσʔϞϯɻԿͰॻ͔Ε͍ͯΔ͔ҙ ࣝ͢Δ͜ͱͳ͍ • ΠϯλʔϑΣΠεHTTP APIɻcurlͰͳΜͰୟ͚Δ
͠ड͚ΒΕΔɻυΩϡϝϯτͰnetcatΛ͍ͬͯΔ • Perl5WebAppͷऑΛิ͏ͨΊʹੜ·Εͨͷ͕ kuiperbelt
Perl5WebAppͷऑͱʁ kuiperbeltͷੜ·ΕͨॠؒΛͨͲΔ
࡞Ζ͏ͱࢥͬͨલ ۭલͷAnyEventϚΠϒʔϜ • Mishima.pm#01ͰAnyEventͱ͔δϣϒΩϡʔ ͷͰΓ্͕Δ • Hachioji.pmͰYanchaͱ͍͏νϟοτΞϓϦͷ ։ൃ͕ਐΜͰ͍ͨ(AnyEventͰWebSocketΛ ड͚Δߏͩͬͨ)
Perl5ͰWebSocketΛड͚Δʹ • Net::WebSocket, Mojo::WebSocket… • ΠϕϯτۦಈϥΠϒϥϦ • TwiggyͳͲΛͬͯҰͭͷϓϩηεͰෳ ͷଓΛ࣋ͯΔ
ΠϕϯτۦಈͷσϝϦοτ • ϒϩοΩϯάಈ࡞Λߦ͏ॲཧ͕ॻ͚ͳ͍ • ී௨ʹDBI͏ͱ͔(τϥϯβΫγϣϯͱ͔) • ී௨ʹϑΝΠϧIO͏ͱ͔ • ී௨ʹAPIϦΫΤετ͢Δͱ͔ •
શ͕ͯίʔϧόοΫܗࣜͰॻ͘Α͏ʹͳΔ
Q: ԿނAnyEvent͕ඞཁ͔ʁ ↓ A: Ұͭͷϓϩηε͕ෳͷ ଓΛ࣋ͯͳ͍ͱͬͯΒΕͳ ͍(C10k Problem)
ී௨ͷPreforkϞσϧͳ WebAppΛॻ͖ͭͭ ͪΐͬ͜ͱ͚ͩWebSocketʹ Ͱ͖ͳ͍͔
WebSocketͷଓΛ࣋ͭ෦ ͚ͩʮ୭͔ʯʹͬͯΒ͑ Ε͍͍ͷͰͳ͍͔ʁ ͦͷਓͱHTTPͰ͠ΌΕ ී௨ʹPerlͰϦΞϧλΠϜΞ ϓϦ͕ॻ͚Δ
͓खܰʹϚϧνεϨουΛॻ ͚Δݴޠͱͯ͠GoΛ࠾༻
2014-06-21
͔͜͠͠ͷͱ͖WebSocket ͦ͠͏ͩͬͨͷͰ Server Sent Eventతͳϓϩτ ίϧͰ࣮
2015-10-21 WebSocketͰશ໘తʹॻ͖͢
2015-10-21 WebSocketͰશ໘తʹॻ͖͢ ࣮Perlͷίʔυ͕͋Γ·͢
“sample psgi app” • ϑϩʔͳͲΛఆٛͯ͠Έͨͷͷ࣮ࡍͷΞϓ Ϧॻ͍ͯΈͳ͍ͱ͜ΕͰ͍͚Δ͔͔ΒΜͳ ͱͳͬͨ • ୈҰݴޠ͕PerlͳͷͰϖϥΠνPSGIͰνϟο τΞϓϦΛॻ͍ͯΈͯػೳ͢Δ͔Λॻ͍ͯΈ
ͨ
ͦͷޙ • ࣾͰʮͬͯ͘ΕʙʯͬͯԿճ͔ϓϨθϯ͢ Δ • ࣮ࡍʹݕ౼͕࢝·ΓಋೖΞϓϦͷϑΟʔυόο ΫΛड͚ΔܗͰػೳՃ • strict broadcast
• application/octet-stream
ͦͷޙ • fujiwara͞ΜʹϕϯνϚʔΫॻ͍ͯΒͬͯ νϡʔχϯάͯ͠Β͏ • ͦΕΛݟͯଞͷϓϩδΣΫτͰಋೖݕ౼͕ ͕Δ
ࢥ1 -> ʹప͢Δ
ʮ͍ΒΜ͜ͱ͠ͳ͍ʯϝιου • ͋͘·Ͱʮଓཧʯʮϝοηʔδ৴ʯʹప ͢Δ • ϝοηʔδͷதಡ·ͳ͍ • ͍͜͠ͱΛΒͳ͍ • ͜͏ͳͬͨΒ͜͏ͳΔΈ͍ͨͳͷ͕૾͠
͍͢Έ
ࢥ2 -> Կ͔ʹґଘ͠ͳ͍
stretcher͔Βͷֶͼ • fujiwara͞ΜͷpullܕσϓϩΠπʔϧstretcher ʹ͓͍ͯσϓϩΠΛ͑Δ܅ͱtarballΛஔ͘ ͱ͜Ζ࣮ͳΜͰྑ͍ • Α͘consulͱS3͕ΘΕΔ͕ઐ༻Ͱͳ͍
kuiperbeltͷྫ • ෳͷkuiperbeltΛ͏߹ɺͲͷ kuiperbelt͕ಛఆͷଓΛ͍࣋ͬͯΔ͔ଓ ͞Εͨ࣌ʹϔομʹIPΞυϨεΛೖΕͯ͑ͯ ͘Δ • Α͘Redisʹ֨ೲ͍ͯ͠Δ͕memcachedͰ RDBͰͳΜͰྑ͍
୭͕ԿΛ͍࣋ͬͯΔ͔ΛΫϥΠΞ ϯτ͕அ͢ΔγϟʔσΟϯά • ketamaͳͲͷconsistent hashingΛ༻͍ͨ memcachedͷsharding͔Βண • ͔͠͠kuiperbeltखલʹLBΛஔ͘લఏͳͷ ͰͲ͜ͷkuiperbeltʹͭͳ͛Δ͔Λ੍ޚͰ͖ ͳ͍
-> ܨ͕ͬͨ࣌ʹWebAppଆʹ͑Δ
ӬଓతίωΫγϣϯΛΞϓϦΛ ͢ΔࣄʹΑΔԸܙ • ΞϓϦ͕ӬଓతίωΫγϣϯΛ࣋ͭͱߋ৽࣌ͳͲͰίωΫγϣ ϯ͕ΕΔ • ࠶ଓͰҰؾʹෛՙ͕͔͔ͬͨΓετϨε͕ཷ·ͬͨΓ͢ Δ • ͋·ΓϩδοΫΛ࣋ͨͣߋ৽Λ͢Δඞཁ͕ͳ͍αʔό͕ίωΫ
γϣϯΛ࣋ͭ͜ͱͰΞϓϦߋ৽࣌ʹஅ͕ى͜Βͳ͘ͳΔ • ͱ͍͏Θ͚ͰGoͷϓϩδΣΫτͰ࠾༻͞ΕΔΑ͏ʹͳΓ ·ͨ͠
૾͍͢͠Έ ґଘΛۃྗͳ͘͢͜ͱͰ ΘΕ͘͢͢Δ
ͦΜͳ͜ΜͳͰ
·ͱΊ • kuiperbeltͱ͍͏WebSocketΛҡ࣋ͯ͘͠ΕΔσʔϞϯΛ ॻ͍͍ͯ·͢ • kuiperbeltPerl5 loveͰ͢ɻผʹޙΖͳΜͰ͍͍͚Ε Ͳ࡞ऀతʹPerl5ͷͨΊʹॻ͔Ε͍ͯ·͢ • Ұ෦͚͍ͩ͠ͱ͜ΖΛΓग़͢ͷΧοίΠΠ
• ͬͯײΛฉ͔ͤͯ͘ΕʂʂɹຊޠυΩϡϝϯτॻ ͍ͨͧʂʂʂɹཔΉʂʂʂʂʂ