SlideShare a Scribd company logo
Akka
Developing SEDA Based
      Applications
Me
Ben Darfler

@bdarfler
http://bdarfler.com
Senior Software Engineer at Localytics
Localytics
Real time mobile analytics platform

40M+ events per day and growing rapidly

3x growth over the past 3 months

Heavy users of Scala/Akka/NoSql
We are hiring (seriously, come talk to me)
Localytics


How to keep up with our growth?
Actor Model
Lock free approach to concurrency
No shared state between actors
Asynchronous message passing
Mailboxes to buffer incoming messages
Akka
Configurable
 ● Dispatchers
 ● Mailboxes

Fault Tolerant
 ● Supervisors

Great community
 ● @jboner
 ● @viktorklang
Akka
                                       Performant




http://blog.jayway.com/2010/08/10/yet-another-akka-benchmark/
SEDA
Staged Event Driven Architecture

"Decomposes a complex, event-driven
application into a set of stages connected
by queues."               1




"The most fundamental aspect of the SEDA
architecture is the programming model that
supports stage-level backpressure and load
management."                   1




1. http://www.eecs.harvard.edu/~mdw/proj/seda/
Backpressure


     Whats the big deal?
Backpressure
Manditory to prevent OutOfMemoryError
 ● Messages backup in memory faster than they
   can be processed

Cassandra was seriously bitten by this
 ● Less crappy failure mode when swamped with
   inserts than "run out of memory and gc-storm
   to death" (CASSANDRA-401)
 ● Add backpressure to StorageProxy
   (CASSANDRA-685)
Backpressure
Mailboxes
case class UnboundedMailbox(val blocking: Boolean = false) extends MailboxType

case class BoundedMailbox(
  val blocking: Boolean = false,
  val capacity: Int = {
     if (Dispatchers.MAILBOX_CAPACITY < 0) Int.MaxValue
     else Dispatchers.MAILBOX_CAPACITY
   },
  val pushTimeOut: Duration = Dispatchers.MAILBOX_PUSH_TIME_OUT
) extends MailboxType



Backpressure Mailbox
BoundedMailbox(false, QUEUE_SIZE, Duration(-1, "millis"))
Stages


  How do we decompose the problem?
Stages
One actor class per stage

Shared dispatcher

Individually tunable
 ● I/O Bound
 ● CPU Bound

Easier to reason about

Code reuse
Dispatchers
ThreadBasedDispatcher
 ● Binds one actor to its own thread

ExecutorBasedEventDrivenDispatcher
 ● Must be shared between actors

ExecutorBasedEventDrivenWorkStealingDispatcher
 ● Must be shared between actors of the same type
Queues

  SEDA has a queue per stage model

  Akka actors have their own mailbox

  How do we evenly distribute work?
Work Stealing
ExecutorBasedEventDrivenWorkStealingDispatcher

"Actors of the same type can be set up to share this
dispatcher and during execution time the different
actors will steal messages from other actors if they
have less messages to process"            1




1. http://doc.akka.io/dispatchers-scala
Work Stealing
Really a work "donating" dispatcher

  "I have implemented a work stealing dispatcher for
Akka actors. Although its called "work stealing" the
implementation actually behaves more as "work
donating" because the victim actor takes the initiative.
I.e. it actually donates work to its thief, rather
than having the thief steal work from the victim."                                 1




1. http://janvanbesien.blogspot.com/2010/03/load-balancing-actors-with-work.html
Work Stealing


 Doesn't that conflict with blocking mailboxes?
Work Stealing
Sending actor will block on the receiving actors
mailbox before it can "donate"

Might be fixed in Akka 1.1
 ● I owe @viktorklang a test of his latest changes
Load Balancing


  Can we distribute work on the sender side?
Load Balancing
Routing.loadBalancerActor()
 ● Creates a new actor that forwards
   messages in a load balancing fashion

InfiniteIterator
 ● CyclicIterator
 ● SmallestMailboxFirstIterator
Load Balancing


Doesn't the load balancer need a blocking mailbox?
Load Balancing
Can't easily change the load balancer's mailbox

Use SmallestMailboxFirstIterator directly
new SmallestMailboxFirstIterator(List(actor, actor, actor))
Fault Tolerance
Supervisors
 ● Restarts actors
 ● Stops after x times within y milliseconds

Restart Strategies
 ● OneForOne
 ● AllForOne
Fault Tolerance
Great for transient issues
 ● Network failures

Not great for permanent issues
 ● OutOfMemoryError
Final Product
// Actor creation
val supervisor = Supervisor(SupervisorConfig(
   OneForOneStrategy(List(classOf[Exception]), RETRIES, WITH_IN_TIME),
   Supervise(myActors))

def
myActors
: List[Supervise] = {
  val mailbox = BoundedMailbox(false, QUEUE_SIZE, Duration(-1, "millis"))
  val dispatcher =
    Dispatchers.newExecutorBasedEventDrivenDispatcher(
    "my-dispatcher", 1, mailbox).setCorePoolSize(POOL_SIZE).build
  (1 to POOL_SIZE toList).foldRight(List[Supervise]()) {
    (i, list) =>
     Supervise(actorOf(new MyActor("my-actor-" + i, dispatcher)), Permanent) :: list
  }
}

// Sending a message
val actors = new SmallestMailboxFirstIterator(actorsFor(classOf[MyActor]).toList)
def actor = actors.next
actor ! Message()
Thanks

          @bdarfler
     http://bdarfler.com
Ad

More Related Content

What's hot (20)

React js
React jsReact js
React js
Alireza Akbari
 
Scaling React and Redux at IOOF
Scaling React and Redux at IOOFScaling React and Redux at IOOF
Scaling React and Redux at IOOF
Vivian Farrell
 
React.js
React.jsReact.js
React.js
Łukasz Kużyński
 
A Brief Introduction to React.js
A Brief Introduction to React.jsA Brief Introduction to React.js
A Brief Introduction to React.js
Doug Neiner
 
React introduction
React introductionReact introduction
React introduction
Kashyap Parmar
 
React JS: A Secret Preview
React JS: A Secret PreviewReact JS: A Secret Preview
React JS: A Secret Preview
valuebound
 
React.js+Redux Workshops
React.js+Redux WorkshopsReact.js+Redux Workshops
React.js+Redux Workshops
Marcin Grzywaczewski
 
Introduce Flux & react in practices (KKBOX)
Introduce Flux & react in practices (KKBOX)Introduce Flux & react in practices (KKBOX)
Introduce Flux & react in practices (KKBOX)
Hsuan Fu Lien
 
Learning React - I
Learning React - ILearning React - I
Learning React - I
Mitch Chen
 
React js
React jsReact js
React js
Rajesh Kolla
 
React js
React jsReact js
React js
Jai Santhosh
 
Academy PRO: React JS
Academy PRO: React JSAcademy PRO: React JS
Academy PRO: React JS
Binary Studio
 
Intro to React
Intro to ReactIntro to React
Intro to React
Eric Westfall
 
React js Rahil Memon
React js Rahil MemonReact js Rahil Memon
React js Rahil Memon
RahilMemon5
 
reactJS
reactJSreactJS
reactJS
Syam Santhosh
 
Breaking the Server-Client Divide with Node.js and React
Breaking the Server-Client Divide with Node.js and ReactBreaking the Server-Client Divide with Node.js and React
Breaking the Server-Client Divide with Node.js and React
Dejan Glozic
 
Introduction to React JS for beginners
Introduction to React JS for beginners Introduction to React JS for beginners
Introduction to React JS for beginners
Varun Raj
 
React js
React jsReact js
React js
Nikhil Karkra
 
001. Introduction about React
001. Introduction about React001. Introduction about React
001. Introduction about React
Binh Quan Duc
 
How to Redux
How to ReduxHow to Redux
How to Redux
Ted Pennings
 
Scaling React and Redux at IOOF
Scaling React and Redux at IOOFScaling React and Redux at IOOF
Scaling React and Redux at IOOF
Vivian Farrell
 
A Brief Introduction to React.js
A Brief Introduction to React.jsA Brief Introduction to React.js
A Brief Introduction to React.js
Doug Neiner
 
React JS: A Secret Preview
React JS: A Secret PreviewReact JS: A Secret Preview
React JS: A Secret Preview
valuebound
 
Introduce Flux & react in practices (KKBOX)
Introduce Flux & react in practices (KKBOX)Introduce Flux & react in practices (KKBOX)
Introduce Flux & react in practices (KKBOX)
Hsuan Fu Lien
 
Learning React - I
Learning React - ILearning React - I
Learning React - I
Mitch Chen
 
Academy PRO: React JS
Academy PRO: React JSAcademy PRO: React JS
Academy PRO: React JS
Binary Studio
 
React js Rahil Memon
React js Rahil MemonReact js Rahil Memon
React js Rahil Memon
RahilMemon5
 
Breaking the Server-Client Divide with Node.js and React
Breaking the Server-Client Divide with Node.js and ReactBreaking the Server-Client Divide with Node.js and React
Breaking the Server-Client Divide with Node.js and React
Dejan Glozic
 
Introduction to React JS for beginners
Introduction to React JS for beginners Introduction to React JS for beginners
Introduction to React JS for beginners
Varun Raj
 
001. Introduction about React
001. Introduction about React001. Introduction about React
001. Introduction about React
Binh Quan Duc
 

Similar to Akka - Developing SEDA Based Applications (20)

Akka (1)
Akka (1)Akka (1)
Akka (1)
Rahul Shukla
 
Akka london scala_user_group
Akka london scala_user_groupAkka london scala_user_group
Akka london scala_user_group
Skills Matter
 
Akka Microservices Architecture And Design
Akka Microservices Architecture And DesignAkka Microservices Architecture And Design
Akka Microservices Architecture And Design
Yaroslav Tkachenko
 
Reactive Streams - László van den Hoek
Reactive Streams - László van den HoekReactive Streams - László van den Hoek
Reactive Streams - László van den Hoek
RubiX BV
 
Introduction to concurrent programming with akka actors
Introduction to concurrent programming with akka actorsIntroduction to concurrent programming with akka actors
Introduction to concurrent programming with akka actors
datamantra
 
Introduction to concurrent programming with Akka actors
Introduction to concurrent programming with Akka actorsIntroduction to concurrent programming with Akka actors
Introduction to concurrent programming with Akka actors
Shashank L
 
Akka lsug skills matter
Akka lsug skills matterAkka lsug skills matter
Akka lsug skills matter
Skills Matter
 
Scaling Web Apps with Akka
Scaling Web Apps with AkkaScaling Web Apps with Akka
Scaling Web Apps with Akka
Maciej Matyjas
 
Building large scale, job processing systems with Scala Akka Actor framework
Building large scale, job processing systems with Scala Akka Actor frameworkBuilding large scale, job processing systems with Scala Akka Actor framework
Building large scale, job processing systems with Scala Akka Actor framework
Vignesh Sukumar
 
Actor model in F# and Akka.NET
Actor model in F# and Akka.NETActor model in F# and Akka.NET
Actor model in F# and Akka.NET
Riccardo Terrell
 
The Pillars Of Concurrency
The Pillars Of ConcurrencyThe Pillars Of Concurrency
The Pillars Of Concurrency
aviade
 
Unifying Messaging, Queueing & Light Weight Compute Using Apache Pulsar
Unifying Messaging, Queueing & Light Weight Compute Using Apache PulsarUnifying Messaging, Queueing & Light Weight Compute Using Apache Pulsar
Unifying Messaging, Queueing & Light Weight Compute Using Apache Pulsar
Karthik Ramasamy
 
Reactive programming with examples
Reactive programming with examplesReactive programming with examples
Reactive programming with examples
Peter Lawrey
 
Developing Microservices using Spring - Beginner's Guide
Developing Microservices using Spring - Beginner's GuideDeveloping Microservices using Spring - Beginner's Guide
Developing Microservices using Spring - Beginner's Guide
Mohanraj Thirumoorthy
 
Agile Lab_BigData_Meetup_AKKA
Agile Lab_BigData_Meetup_AKKAAgile Lab_BigData_Meetup_AKKA
Agile Lab_BigData_Meetup_AKKA
Paolo Platter
 
Fundamentals of Akka - Webinar
Fundamentals of Akka - WebinarFundamentals of Akka - Webinar
Fundamentals of Akka - Webinar
Knoldus Inc.
 
Scale up your thinking
Scale up your thinkingScale up your thinking
Scale up your thinking
Yardena Meymann
 
Akka.Net Overview
Akka.Net OverviewAkka.Net Overview
Akka.Net Overview
Geoffrey Vandiest
 
Let the alpakka pull your stream
Let the alpakka pull your streamLet the alpakka pull your stream
Let the alpakka pull your stream
Enno Runne
 
Flink Forward SF 2017: Feng Wang & Zhijiang Wang - Runtime Improvements in Bl...
Flink Forward SF 2017: Feng Wang & Zhijiang Wang - Runtime Improvements in Bl...Flink Forward SF 2017: Feng Wang & Zhijiang Wang - Runtime Improvements in Bl...
Flink Forward SF 2017: Feng Wang & Zhijiang Wang - Runtime Improvements in Bl...
Flink Forward
 
Akka london scala_user_group
Akka london scala_user_groupAkka london scala_user_group
Akka london scala_user_group
Skills Matter
 
Akka Microservices Architecture And Design
Akka Microservices Architecture And DesignAkka Microservices Architecture And Design
Akka Microservices Architecture And Design
Yaroslav Tkachenko
 
Reactive Streams - László van den Hoek
Reactive Streams - László van den HoekReactive Streams - László van den Hoek
Reactive Streams - László van den Hoek
RubiX BV
 
Introduction to concurrent programming with akka actors
Introduction to concurrent programming with akka actorsIntroduction to concurrent programming with akka actors
Introduction to concurrent programming with akka actors
datamantra
 
Introduction to concurrent programming with Akka actors
Introduction to concurrent programming with Akka actorsIntroduction to concurrent programming with Akka actors
Introduction to concurrent programming with Akka actors
Shashank L
 
Akka lsug skills matter
Akka lsug skills matterAkka lsug skills matter
Akka lsug skills matter
Skills Matter
 
Scaling Web Apps with Akka
Scaling Web Apps with AkkaScaling Web Apps with Akka
Scaling Web Apps with Akka
Maciej Matyjas
 
Building large scale, job processing systems with Scala Akka Actor framework
Building large scale, job processing systems with Scala Akka Actor frameworkBuilding large scale, job processing systems with Scala Akka Actor framework
Building large scale, job processing systems with Scala Akka Actor framework
Vignesh Sukumar
 
Actor model in F# and Akka.NET
Actor model in F# and Akka.NETActor model in F# and Akka.NET
Actor model in F# and Akka.NET
Riccardo Terrell
 
The Pillars Of Concurrency
The Pillars Of ConcurrencyThe Pillars Of Concurrency
The Pillars Of Concurrency
aviade
 
Unifying Messaging, Queueing & Light Weight Compute Using Apache Pulsar
Unifying Messaging, Queueing & Light Weight Compute Using Apache PulsarUnifying Messaging, Queueing & Light Weight Compute Using Apache Pulsar
Unifying Messaging, Queueing & Light Weight Compute Using Apache Pulsar
Karthik Ramasamy
 
Reactive programming with examples
Reactive programming with examplesReactive programming with examples
Reactive programming with examples
Peter Lawrey
 
Developing Microservices using Spring - Beginner's Guide
Developing Microservices using Spring - Beginner's GuideDeveloping Microservices using Spring - Beginner's Guide
Developing Microservices using Spring - Beginner's Guide
Mohanraj Thirumoorthy
 
Agile Lab_BigData_Meetup_AKKA
Agile Lab_BigData_Meetup_AKKAAgile Lab_BigData_Meetup_AKKA
Agile Lab_BigData_Meetup_AKKA
Paolo Platter
 
Fundamentals of Akka - Webinar
Fundamentals of Akka - WebinarFundamentals of Akka - Webinar
Fundamentals of Akka - Webinar
Knoldus Inc.
 
Let the alpakka pull your stream
Let the alpakka pull your streamLet the alpakka pull your stream
Let the alpakka pull your stream
Enno Runne
 
Flink Forward SF 2017: Feng Wang & Zhijiang Wang - Runtime Improvements in Bl...
Flink Forward SF 2017: Feng Wang & Zhijiang Wang - Runtime Improvements in Bl...Flink Forward SF 2017: Feng Wang & Zhijiang Wang - Runtime Improvements in Bl...
Flink Forward SF 2017: Feng Wang & Zhijiang Wang - Runtime Improvements in Bl...
Flink Forward
 
Ad

Recently uploaded (20)

Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
Ad

Akka - Developing SEDA Based Applications

  • 3. Localytics Real time mobile analytics platform 40M+ events per day and growing rapidly 3x growth over the past 3 months Heavy users of Scala/Akka/NoSql We are hiring (seriously, come talk to me)
  • 4. Localytics How to keep up with our growth?
  • 5. Actor Model Lock free approach to concurrency No shared state between actors Asynchronous message passing Mailboxes to buffer incoming messages
  • 6. Akka Configurable ● Dispatchers ● Mailboxes Fault Tolerant ● Supervisors Great community ● @jboner ● @viktorklang
  • 7. Akka Performant http://blog.jayway.com/2010/08/10/yet-another-akka-benchmark/
  • 8. SEDA Staged Event Driven Architecture "Decomposes a complex, event-driven application into a set of stages connected by queues." 1 "The most fundamental aspect of the SEDA architecture is the programming model that supports stage-level backpressure and load management." 1 1. http://www.eecs.harvard.edu/~mdw/proj/seda/
  • 9. Backpressure Whats the big deal?
  • 10. Backpressure Manditory to prevent OutOfMemoryError ● Messages backup in memory faster than they can be processed Cassandra was seriously bitten by this ● Less crappy failure mode when swamped with inserts than "run out of memory and gc-storm to death" (CASSANDRA-401) ● Add backpressure to StorageProxy (CASSANDRA-685)
  • 11. Backpressure Mailboxes case class UnboundedMailbox(val blocking: Boolean = false) extends MailboxType case class BoundedMailbox( val blocking: Boolean = false, val capacity: Int = { if (Dispatchers.MAILBOX_CAPACITY < 0) Int.MaxValue else Dispatchers.MAILBOX_CAPACITY }, val pushTimeOut: Duration = Dispatchers.MAILBOX_PUSH_TIME_OUT ) extends MailboxType Backpressure Mailbox BoundedMailbox(false, QUEUE_SIZE, Duration(-1, "millis"))
  • 12. Stages How do we decompose the problem?
  • 13. Stages One actor class per stage Shared dispatcher Individually tunable ● I/O Bound ● CPU Bound Easier to reason about Code reuse
  • 14. Dispatchers ThreadBasedDispatcher ● Binds one actor to its own thread ExecutorBasedEventDrivenDispatcher ● Must be shared between actors ExecutorBasedEventDrivenWorkStealingDispatcher ● Must be shared between actors of the same type
  • 15. Queues SEDA has a queue per stage model Akka actors have their own mailbox How do we evenly distribute work?
  • 16. Work Stealing ExecutorBasedEventDrivenWorkStealingDispatcher "Actors of the same type can be set up to share this dispatcher and during execution time the different actors will steal messages from other actors if they have less messages to process" 1 1. http://doc.akka.io/dispatchers-scala
  • 17. Work Stealing Really a work "donating" dispatcher "I have implemented a work stealing dispatcher for Akka actors. Although its called "work stealing" the implementation actually behaves more as "work donating" because the victim actor takes the initiative. I.e. it actually donates work to its thief, rather than having the thief steal work from the victim." 1 1. http://janvanbesien.blogspot.com/2010/03/load-balancing-actors-with-work.html
  • 18. Work Stealing Doesn't that conflict with blocking mailboxes?
  • 19. Work Stealing Sending actor will block on the receiving actors mailbox before it can "donate" Might be fixed in Akka 1.1 ● I owe @viktorklang a test of his latest changes
  • 20. Load Balancing Can we distribute work on the sender side?
  • 21. Load Balancing Routing.loadBalancerActor() ● Creates a new actor that forwards messages in a load balancing fashion InfiniteIterator ● CyclicIterator ● SmallestMailboxFirstIterator
  • 22. Load Balancing Doesn't the load balancer need a blocking mailbox?
  • 23. Load Balancing Can't easily change the load balancer's mailbox Use SmallestMailboxFirstIterator directly new SmallestMailboxFirstIterator(List(actor, actor, actor))
  • 24. Fault Tolerance Supervisors ● Restarts actors ● Stops after x times within y milliseconds Restart Strategies ● OneForOne ● AllForOne
  • 25. Fault Tolerance Great for transient issues ● Network failures Not great for permanent issues ● OutOfMemoryError
  • 26. Final Product // Actor creation val supervisor = Supervisor(SupervisorConfig( OneForOneStrategy(List(classOf[Exception]), RETRIES, WITH_IN_TIME), Supervise(myActors)) def myActors : List[Supervise] = { val mailbox = BoundedMailbox(false, QUEUE_SIZE, Duration(-1, "millis")) val dispatcher = Dispatchers.newExecutorBasedEventDrivenDispatcher( "my-dispatcher", 1, mailbox).setCorePoolSize(POOL_SIZE).build (1 to POOL_SIZE toList).foldRight(List[Supervise]()) { (i, list) => Supervise(actorOf(new MyActor("my-actor-" + i, dispatcher)), Permanent) :: list } } // Sending a message val actors = new SmallestMailboxFirstIterator(actorsFor(classOf[MyActor]).toList) def actor = actors.next actor ! Message()
  • 27. Thanks @bdarfler http://bdarfler.com