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
Akka Streamsの縮退処理を用いた耐障害性の実現 〜 広告のリアルタイムオークションの...
Search
Ikuo Matsumura
March 26, 2016
Programming
1
2.4k
Akka Streamsの縮退処理を用いた耐障害性の実現 〜 広告のリアルタイムオークションの事例 〜
「Scala将軍達の後の祭り」での発表資料です。
http://scala-syogun-matsuri.connpass.com/event/28124/
Ikuo Matsumura
March 26, 2016
Tweet
Share
More Decks by Ikuo Matsumura
See All by Ikuo Matsumura
論文紹介: "A Unified Search Federation System Based on Online User Feedback"
ikuo
0
97
Other Decks in Programming
See All in Programming
ecspresso, ecschedule, lambroll を PipeCDプラグインとして動かしてみた (プロトタイプ) / Running ecspresso, ecschedule, and lambroll as PipeCD Plugins (prototype)
tkikuc
2
1.9k
混沌とした例外処理とエラー監視に秩序をもたらす
morihirok
13
2.3k
[JAWS-UG横浜 #80] うわっ…今年のServerless アップデート、少なすぎ…?
maroon1st
0
110
最近のVS Codeで気になるニュース 2025/01
74th
1
110
PHPで作るWebSocketサーバー ~リアクティブなアプリケーションを知るために~ / WebSocket Server in PHP - To know reactive applications
seike460
PRO
2
770
毎日13時間もかかるバッチ処理をたった3日で60%短縮するためにやったこと
sho_ssk_
1
550
Swiftコンパイラ超入門+async関数の仕組み
shiz
0
180
traP の部内 ISUCON とそれを支えるポータル / PISCON Portal
ikura_hamu
0
190
アクターシステムに頼らずEvent Sourcingする方法について
j5ik2o
6
710
php-conference-japan-2024
tasuku43
0
430
AppRouterを用いた大規模サービス開発におけるディレクトリ構成の変遷と問題点
eiganken
1
450
AHC041解説
terryu16
0
400
Featured
See All Featured
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
The Power of CSS Pseudo Elements
geoffreycrofte
74
5.4k
Docker and Python
trallard
43
3.2k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
8
1.2k
4 Signs Your Business is Dying
shpigford
182
22k
jQuery: Nuts, Bolts and Bling
dougneiner
62
7.6k
Six Lessons from altMBA
skipperchong
27
3.6k
Building Applications with DynamoDB
mza
93
6.2k
Gamification - CAS2011
davidbonilla
80
5.1k
Practical Orchestrator
shlominoach
186
10k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
330
21k
Making Projects Easy
brettharned
116
6k
Transcript
Akka StreamsͷॖୀॲཧΛ༻͍ͨ োੑͷ࣮ݱ ʙ ࠂͷϦΞϧλΠϜΦʔΫγϣϯͷࣄྫ ʙ
ࣗݾհ @ikuo (Ikuo Matsumura) 2008~ ࠐܥͷࢄγϛϡϨʔγϣϯͷઃܭ։ൃͳͲ; C++, MATLAB IBM Research
- Tokyo 2011~ ϨγϐӫཆՁͷࣗಈܭࢉͷઃܭ։ൃͳͲ; Ruby/Rails, Treetop Cookpad, Inc. 2014~ SSP/RTBΦʔΫγϣϯͷઃܭ։ൃͳͲ; Scala/Akka CyberAgent, Inc. CA ProFit-X team
ࠂͷϦΞϧλΠϜΦʔΫγϣϯ (RTB) ߴ͍Մ༻ੑཁ݅ɿࢭΊΒΕͳ͍ ˍ ͬͯ͘Εͳ͍ ෆ࣮֬ͳڥɿ֎෦ͷଟͷೖࡳݩ(DSP)ʹৗ࣌ଓ ೖࡳ͕શͯἧΘͳ͍͜ͱڐ༰Ͱ͖Δ
ଟͷ֎෦ଓͷো͔ΒγεςϜΛकΓ͍ͨ * Photo by FEMA/Joselyne Augus5no; A home in Gilchrist,
Texas, designed to resist flood waters survived Hurricane Ike in 2008.
֎෦ଓͷোͱΞϓϩʔν ʮͪ͜Βʯͷҟৗɿଓͷ෦ঢ়ଶͷҟৗ ྫɿHTTP ΫϥΠΞϯτͷActorͷঢ়ଶҟৗ → SupervisorʹΑΔҟৗݕͱActorͷ࠶ىಈ ʮ͋ͪΒʯͷҟৗɿϨΠςϯγѱԽɾແԠԽ ྫɿଓઌͷܭࢉࢿݯଳҬͷṧഭ → ॖୀ
(fallback)ɿॏཁͰͳ͍ϝοηʔδΛࣺͯͯ ɹɹϝϞϦރׇ (OutOfMemoryError) Λ͙
ରࡦ1: BoundedMailboxΛ͏ bounded-mailbox { mailbox-type = "akka.dispatch.NonBlockingBoundedMailbox" } ✅ ᷓΕͨΒϝοηʔδࣺͯΔͷͰϝϞϦރׇ͛Δ
❌ Ձͷߴ͍ϝοηʔδ͕ࣺͯΒΕΔ ؒʹ߹͏ݟࠐΈͷখ͍͞ೖࡳཁٻ͕ͬͯ͠·͏
ରࡦ2: ༏ઌ͖ͭͷBoundedMailboxΛ͏ bounded-mailbox { mailbox-type = "akka.dispatch.BoundedStablePriorityMailbox" mailbox-push-timeout-time = 0s
} ✅ ᷓΕͨΒϝοηʔδࣺͯΔͷͰϝϞϦރׇ͛Δ ✅ Ձͷߴ͍ϝοηʔδΛͤΔ
❌ ద༻࿙ΕͷActor͕͋ΔͱϝϞϦރׇ͛ͳ͍ UnboundedͳϝʔϧϘοΫεͷActor͕͋Γɺ͕ͦ͜ ʹͳΔͱϝʔϧϘοΫε͕ᷓΕΔ
ରࡦ3: Akka StreamsΛ͏ ϝοηʔδִนϊʔυ (bulkhead) Λհͯ͠௨৴ϊʔυ (subscriber) ʹBroadcastɻ ௨৴ϊʔυ֎෦ཁٻྃ·ͰϝοηʔδΛ্ྲྀʹཁٻ͠ͳ͍ɻ
ִนϊʔυ (bulkhead) val bulkhead = Flow .apply[MyMessage] .buffer( bulkheadBufferSize, OverflowStrategy.dropHead
) όοϑΝͷ࠷େαΠζΛ͑Δͱɺݹ͍ϝοηʔδ ΛࣺͯΔ ( dropHead )
௨৴ϊʔυ (subscriber) val subscriberA = Sink(ActorSubscriber[MyMessage](actorA)) class ProxyA extends Actor
with ActorSubscriber { def receive = { case OnNext(msg: MyMessage) => hostConnector .ask(httpReq(msg)) .map(...) .onComplete(request(1)) ... ֎෦ཁٻͷྃΛ͔ͬͯΒ࣍ͷϝοηʔδΛ্ྲྀ (bulkhead) ʹཁٻ͢ΔͷͰɺ֎෦ཁٻͷաఔͷͲ͕͜ ʹͳͬͯϝʔϧϘοΫε͕ᷓΕͳ͍
Akka StreamsΛ͏ ✅ ᷓΕͨΒϝοηʔδࣺͯΔͷͰϝϞϦރׇ͛Δ ✅ Ձͷߴ͍ϝοηʔδΛͤΔ ✅ ཁҼ͕Ҡಈ࣮ͯ֬͠ʹॖୀͰ͖Δ
CA ProFit-X • 20153݄ʹϦϦʔε • ॳ͔ΒAkka StreamsʹΑΔ ॖୀॲཧΛࠐΈ • ݱࡏඵؒ1ສ݅ͷϦΞϧλ
ΠϜΦʔΫγϣϯΛ҆ఆͯ͠ ॲཧ
·ͱΊ Akka StreamsΛ֎෦ଓͷॖୀͷͨΊʹ͏͜ͱ Ͱɺʮͬͯ͘Εͳ͍ʯڥͰ֎෦ଓͷোʢੑ ೳྼԽ ) ͔ΒγεςϜΛकΔྫΛհ͠·ͨ͠ɻ ॲཧͱผͷ োੑ ͷଆ໘ͰAkka
StreamsΛ ׆༻͢Δྫͷ1ͭͱͯ͠ɺࢀߟʹͳΕ͍Ͱ͢ɻ