Akka Streamsの縮退処理を用いた耐障害性の実現 〜 広告のリアルタイムオークションの事例 〜
by
Ikuo Matsumura
Link
Embed
Share
Beginning
This slide
Copy link URL
Copy link URL
Copy iframe embed code
Copy iframe embed code
Copy javascript embed code
Copy javascript embed code
Share
Tweet
Share
Tweet
Slide 1
Slide 1 text
Akka StreamsͷॖୀॲཧΛ༻͍ͨ োੑͷ࣮ݱ ʙ ࠂͷϦΞϧλΠϜΦʔΫγϣϯͷࣄྫ ʙ
Slide 2
Slide 2 text
ࣗݾհ @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
Slide 3
Slide 3 text
ࠂͷϦΞϧλΠϜΦʔΫγϣϯ (RTB) ߴ͍Մ༻ੑཁ݅ɿࢭΊΒΕͳ͍ ˍ ͬͯ͘Εͳ͍ ෆ࣮֬ͳڥɿ֎෦ͷଟͷೖࡳݩ(DSP)ʹৗ࣌ଓ ೖࡳ͕શͯἧΘͳ͍͜ͱڐ༰Ͱ͖Δ
Slide 4
Slide 4 text
ଟͷ֎෦ଓͷো͔ΒγεςϜΛकΓ͍ͨ * Photo by FEMA/Joselyne Augus5no; A home in Gilchrist, Texas, designed to resist flood waters survived Hurricane Ike in 2008.
Slide 5
Slide 5 text
֎෦ଓͷোͱΞϓϩʔν ʮͪ͜Βʯͷҟৗɿଓͷ෦ঢ়ଶͷҟৗ ྫɿHTTP ΫϥΠΞϯτͷActorͷঢ়ଶҟৗ → SupervisorʹΑΔҟৗݕͱActorͷ࠶ىಈ ʮ͋ͪΒʯͷҟৗɿϨΠςϯγѱԽɾແԠԽ ྫɿଓઌͷܭࢉࢿݯଳҬͷṧഭ → ॖୀ (fallback)ɿॏཁͰͳ͍ϝοηʔδΛࣺͯͯ ɹɹϝϞϦރׇ (OutOfMemoryError) Λ͙
Slide 6
Slide 6 text
ରࡦ1: BoundedMailboxΛ͏ bounded-mailbox { mailbox-type = "akka.dispatch.NonBlockingBoundedMailbox" } ✅ ᷓΕͨΒϝοηʔδࣺͯΔͷͰϝϞϦރׇ͛Δ
Slide 7
Slide 7 text
❌ Ձͷߴ͍ϝοηʔδ͕ࣺͯΒΕΔ ؒʹ߹͏ݟࠐΈͷখ͍͞ೖࡳཁٻ͕ͬͯ͠·͏
Slide 8
Slide 8 text
ରࡦ2: ༏ઌ͖ͭͷBoundedMailboxΛ͏ bounded-mailbox { mailbox-type = "akka.dispatch.BoundedStablePriorityMailbox" mailbox-push-timeout-time = 0s } ✅ ᷓΕͨΒϝοηʔδࣺͯΔͷͰϝϞϦރׇ͛Δ ✅ Ձͷߴ͍ϝοηʔδΛͤΔ
Slide 9
Slide 9 text
❌ ద༻࿙ΕͷActor͕͋ΔͱϝϞϦރׇ͛ͳ͍ UnboundedͳϝʔϧϘοΫεͷActor͕͋Γɺ͕ͦ͜ ʹͳΔͱϝʔϧϘοΫε͕ᷓΕΔ
Slide 10
Slide 10 text
ରࡦ3: Akka StreamsΛ͏ ϝοηʔδִนϊʔυ (bulkhead) Λհͯ͠௨৴ϊʔυ (subscriber) ʹBroadcastɻ ௨৴ϊʔυ֎෦ཁٻྃ·ͰϝοηʔδΛ্ྲྀʹཁٻ͠ͳ͍ɻ
Slide 11
Slide 11 text
ִนϊʔυ (bulkhead) val bulkhead = Flow .apply[MyMessage] .buffer( bulkheadBufferSize, OverflowStrategy.dropHead ) όοϑΝͷ࠷େαΠζΛ͑Δͱɺݹ͍ϝοηʔδ ΛࣺͯΔ ( dropHead )
Slide 12
Slide 12 text
௨৴ϊʔυ (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) ʹཁٻ͢ΔͷͰɺ֎෦ཁٻͷաఔͷͲ͕͜ ʹͳͬͯϝʔϧϘοΫε͕ᷓΕͳ͍
Slide 13
Slide 13 text
Akka StreamsΛ͏ ✅ ᷓΕͨΒϝοηʔδࣺͯΔͷͰϝϞϦރׇ͛Δ ✅ Ձͷߴ͍ϝοηʔδΛͤΔ ✅ ཁҼ͕Ҡಈ࣮ͯ֬͠ʹॖୀͰ͖Δ
Slide 14
Slide 14 text
CA ProFit-X • 20153݄ʹϦϦʔε • ॳ͔ΒAkka StreamsʹΑΔ ॖୀॲཧΛࠐΈ • ݱࡏඵؒ1ສ݅ͷϦΞϧλ ΠϜΦʔΫγϣϯΛ҆ఆͯ͠ ॲཧ
Slide 15
Slide 15 text
·ͱΊ Akka StreamsΛ֎෦ଓͷॖୀͷͨΊʹ͏͜ͱ Ͱɺʮͬͯ͘Εͳ͍ʯڥͰ֎෦ଓͷোʢੑ ೳྼԽ ) ͔ΒγεςϜΛकΔྫΛհ͠·ͨ͠ɻ ॲཧͱผͷ োੑ ͷଆ໘ͰAkka StreamsΛ ׆༻͢Δྫͷ1ͭͱͯ͠ɺࢀߟʹͳΕ͍Ͱ͢ɻ