Akka (BeJUG)

Akka Actors




@Sander_Mak
Akka
              Part of



              stack

Written in Scala
With officially supported Java API
Akka

     ‘s premise
It’s too hard to write systems that are:

  Concurrent & Correct
  Highly scalable
  Fault-tolerant
Akka

   2.0
Actors
Software Transactional Memory
Dataflow concurrency
Futures
Akka
who uses



           ?
               traffic management
Actors
Inspired by               :


    Asynchronous message passing
    Scale up, scale out
    Fault-tolerant (‘let it crash’)
Actors
How to define an actor?
                         ~400 bytes




                         Local state

                          Behavior




               mailbox
Actors
How to define an actor?
                              ~400 bytes
  Create more actors
  Send messages
  Modify state                Local state

  Modify behavior              Behavior




                    mailbox
Actors
How to define an actor?


class MyFirstActor extends Actor {
  var total = 0

    def receive = {
      case MyMessage(payload) => println(“Received: “ + payload”)
      case countMessage: Int => total += countMessage
      case _ => println("Unknown message")
    }
}
Actors
Dispatcher: contains executor strategy




                           Local state
       Event-driven
                           Behavior




                 mailbox
Actors and Fork/Join
Ping/pong messages (no processing)




                   Improved
 48
                 JSR-166 build (     ?)
cores
Demo
                 NearestCityActor
                 NearestCityActor
                  NearestCityActor
                  NearestCityActor



  RoundRobin                       Result
    Router                     ListenerActor



Messages with cities             Print results
Supervision
Hierarchical supervision
 Child actors supervised by parent
Trap exceptions and apply recovery
Error Kernel pattern

 Actor 1     create child
                actor
                            Actor 2   dangerous
                                      operation
  critical
   state      supervise




Distinguish scratch and critical state
Supervision
class GuardianActor extends Actor {

    def supervisorStrategy = OneForOneStrategy({
        case _:CompanyBankruptException    => Stop
        case _:InvalidStateException       => Restart
        case _:ServiceUnavailableException => Resume
        case _                             => Escalate
     }, maxNrOfRetries = 3, 5.seconds)

    def receive = {
      ...
    }
}




             Actor may implement
            preRestart & postRestart
Remote actors
Dispatchers for scale-up, remote actors for scala-out


   Machine A                           Machine B
                    actor2 ! SomeMsg
      Actor 1                           Actor 2
                     Netty, Protobuf



      Router                            Actor 3


   Actor creation
   Supervision
   Remote deploy through config (no code change)
Remote actors
Creating 10 actors on 2 nodes with a router
 akka	
  {
 	
  	
  actor	
  {
 	
  	
  	
  	
  deployment	
  {
 	
  	
  	
  	
  	
  	
  /serviceA/aggregation	
  {
 	
  	
  	
  	
  	
  	
  	
  	
  router	
  =	
  "round-­‐robin"
 	
  	
  	
  	
  	
  	
  	
  	
  nr-­‐of-­‐instances	
  =	
  10
 	
  	
  	
  	
  	
  	
  	
  	
  target	
  {
 	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  nodes	
  =	
  ["akka://app@10.0.0.2:2552",	
  "akka://app@10.0.0.3:2552"]
 	
  	
  	
  	
  	
  	
  	
  	
  }
 	
  	
  	
  	
  	
  	
  }
 	
  	
  	
  	
  }
 	
  	
  }
 }




Looking up a remote actor
 val	
  actor	
  =	
  
 	
  	
  	
  context.actorFor("akka://actorSystemName@10.0.0.1:2552/user/actorName")
Blocking
Actors lift some ForkJoin restrictions
    Remoting possible
    Recursive decomposition optional
    Fault-tolerant

Still, there are restrictions similar to ForkJoin tasks

    No blocking IO
    No explicit locking
    No shared memory writes
Async IO
 Based on composable Futures

Serve http
                mini               akka-Spray


Consume http
               async-http-client


Persistence
                hammersmith
Async IO
          Based on Java NIO


Akka IO

   Immutable abstractions on top of:
     Channels
     Streams (Iteratee based)
   Bridges (low-level) async IO and actors
Async IO
       Practical application:




  JMeter => 1 user, 1 thread     Gatling => 1 user, 1 actor
+ blocking IO                   + async-http-client

= OutOfMemory errors            =
  or clustering necessary

  time drift in results
Async IO
       Practical application:




  JMeter => 1 user, 1 thread     Gatling => 1 user, 1 actor
+ blocking IO                   + async-http-client

= OutOfMemory errors            =
  or clustering necessary

  time drift in results
Is that all?
             Finite State Machine          Akka TestKit




 core
          Scheduler                 Event Bus




modules
Is that all?
                   Typesafe
                   Console




Commercial
subscription
Questions?


      Code @ bit.ly/bejug-akka
1 of 24

Recommended

Java 7: Fork/Join, Invokedynamic and the future by
Java 7: Fork/Join, Invokedynamic and the futureJava 7: Fork/Join, Invokedynamic and the future
Java 7: Fork/Join, Invokedynamic and the futureSander Mak (@Sander_Mak)
1.5K views35 slides
Introduction to Actor Model and Akka by
Introduction to Actor Model and AkkaIntroduction to Actor Model and Akka
Introduction to Actor Model and AkkaYung-Lin Ho
5K views37 slides
Introduction to Akka - Atlanta Java Users Group by
Introduction to Akka - Atlanta Java Users GroupIntroduction to Akka - Atlanta Java Users Group
Introduction to Akka - Atlanta Java Users GroupRoy Russo
2.4K views87 slides
The dark side of Akka and the remedy by
The dark side of Akka and the remedyThe dark side of Akka and the remedy
The dark side of Akka and the remedykrivachy
4.5K views59 slides
Open Source Compiler Construction for the JVM by
Open Source Compiler Construction for the JVMOpen Source Compiler Construction for the JVM
Open Source Compiler Construction for the JVMTom Lee
1.2K views14 slides
Java 7 Whats New(), Whats Next() from Oredev by
Java 7 Whats New(), Whats Next() from OredevJava 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from OredevMattias Karlsson
2.2K views84 slides

More Related Content

What's hot

What is Serialization in Java? | Java Tutorial | Edureka by
What is Serialization in Java? | Java Tutorial | EdurekaWhat is Serialization in Java? | Java Tutorial | Edureka
What is Serialization in Java? | Java Tutorial | EdurekaEdureka!
213 views35 slides
Advanced akka features by
Advanced akka featuresAdvanced akka features
Advanced akka featuresGrzegorz Duda
1.5K views112 slides
Actor Model Akka Framework by
Actor Model Akka FrameworkActor Model Akka Framework
Actor Model Akka FrameworkHarinath Krishnamoorthy
361 views30 slides
Java 8 parallel stream by
Java 8 parallel streamJava 8 parallel stream
Java 8 parallel streamYung Chieh Tsai
583 views34 slides
Akka - A Brief Intro by
Akka - A Brief IntroAkka - A Brief Intro
Akka - A Brief IntroThomas Lockney
1.9K views22 slides
JAVA 8 Parallel Stream by
JAVA 8 Parallel StreamJAVA 8 Parallel Stream
JAVA 8 Parallel StreamTengwen Wang
435 views34 slides

What's hot(20)

What is Serialization in Java? | Java Tutorial | Edureka by Edureka!
What is Serialization in Java? | Java Tutorial | EdurekaWhat is Serialization in Java? | Java Tutorial | Edureka
What is Serialization in Java? | Java Tutorial | Edureka
Edureka!213 views
Advanced akka features by Grzegorz Duda
Advanced akka featuresAdvanced akka features
Advanced akka features
Grzegorz Duda1.5K views
JAVA 8 Parallel Stream by Tengwen Wang
JAVA 8 Parallel StreamJAVA 8 Parallel Stream
JAVA 8 Parallel Stream
Tengwen Wang435 views
Akka Futures and Akka Remoting by Knoldus Inc.
Akka Futures  and Akka RemotingAkka Futures  and Akka Remoting
Akka Futures and Akka Remoting
Knoldus Inc.2.1K views
Working With Concurrency In Java 8 by Heartin Jacob
Working With Concurrency In Java 8Working With Concurrency In Java 8
Working With Concurrency In Java 8
Heartin Jacob1.8K views
The internet of (lego) trains by Grzegorz Duda
The internet of (lego) trainsThe internet of (lego) trains
The internet of (lego) trains
Grzegorz Duda652 views
Unit Testing and Coverage for AngularJS by Knoldus Inc.
Unit Testing and Coverage for AngularJSUnit Testing and Coverage for AngularJS
Unit Testing and Coverage for AngularJS
Knoldus Inc.4.8K views
Angular Weekend by Troy Miles
Angular WeekendAngular Weekend
Angular Weekend
Troy Miles1.2K views
Testing in Scala. Adform Research by Vasil Remeniuk
Testing in Scala. Adform ResearchTesting in Scala. Adform Research
Testing in Scala. Adform Research
Vasil Remeniuk967 views
Intro to JavaScript by Yakov Fain
Intro to JavaScriptIntro to JavaScript
Intro to JavaScript
Yakov Fain2K views
Grand Central Dispatch by Robert Brown
Grand Central DispatchGrand Central Dispatch
Grand Central Dispatch
Robert Brown1.4K views
Headless fragments in Android by Ali Muzaffar
Headless fragments in AndroidHeadless fragments in Android
Headless fragments in Android
Ali Muzaffar2.1K views
Understanding react hooks by Maulik Shah
Understanding react hooksUnderstanding react hooks
Understanding react hooks
Maulik Shah1.9K views

Viewers also liked

____,___ by
____,_______,___
____,___Huanyin Cheng
422 views26 slides
Selecting a Digital Banking Platform 2017-2018 by
Selecting a Digital Banking Platform 2017-2018Selecting a Digital Banking Platform 2017-2018
Selecting a Digital Banking Platform 2017-2018Alexey Kononenko
426 views3 slides
Onestival pres by
Onestival presOnestival pres
Onestival presBayan Waleed Shadaideh
437 views50 slides
Presentation2[1] by
Presentation2[1]Presentation2[1]
Presentation2[1]o.m.garcia
178 views3 slides
11 necto installation_ready by
11 necto installation_ready11 necto installation_ready
11 necto installation_readywww.panorama.com
622 views49 slides

Viewers also liked(20)

Selecting a Digital Banking Platform 2017-2018 by Alexey Kononenko
Selecting a Digital Banking Platform 2017-2018Selecting a Digital Banking Platform 2017-2018
Selecting a Digital Banking Platform 2017-2018
Alexey Kononenko426 views
Presentation2[1] by o.m.garcia
Presentation2[1]Presentation2[1]
Presentation2[1]
o.m.garcia178 views
Kosvenie rechevie akty by katyaSh
Kosvenie rechevie aktyKosvenie rechevie akty
Kosvenie rechevie akty
katyaSh310 views
Prioritas Diklat by su7as
Prioritas DiklatPrioritas Diklat
Prioritas Diklat
su7as 1.3K views
Unmanned Video citizin services by ibsis
Unmanned Video citizin servicesUnmanned Video citizin services
Unmanned Video citizin services
ibsis290 views
William turner by katyaSh
William turnerWilliam turner
William turner
katyaSh664 views
Google Doc Ch4 by Warren Yip
Google Doc Ch4Google Doc Ch4
Google Doc Ch4
Warren Yip300 views

Similar to Akka (BeJUG)

Building Massively Scalable application with Akka 2.0 by
Building Massively Scalable application with Akka 2.0Building Massively Scalable application with Akka 2.0
Building Massively Scalable application with Akka 2.0Knoldus Inc.
1.1K views37 slides
Introduction to Actor Model and Akka by
Introduction to Actor Model and AkkaIntroduction to Actor Model and Akka
Introduction to Actor Model and AkkaYung-Lin Ho
15.2K views23 slides
Akka london scala_user_group by
Akka london scala_user_groupAkka london scala_user_group
Akka london scala_user_groupSkills Matter
1.1K views162 slides
First glance at Akka 2.0 by
First glance at Akka 2.0First glance at Akka 2.0
First glance at Akka 2.0Vasil Remeniuk
2.2K views42 slides
JavaOne: A tour of (advanced) akka features in 60 minutes [con1706] by
JavaOne: A tour of (advanced) akka features in 60 minutes [con1706]JavaOne: A tour of (advanced) akka features in 60 minutes [con1706]
JavaOne: A tour of (advanced) akka features in 60 minutes [con1706]Johan Janssen
288 views95 slides
A tour of (advanced) Akka features in 40 minutes by
A tour of (advanced) Akka features in 40 minutesA tour of (advanced) Akka features in 40 minutes
A tour of (advanced) Akka features in 40 minutesJohan Janssen
285 views95 slides

Similar to Akka (BeJUG)(20)

Building Massively Scalable application with Akka 2.0 by Knoldus Inc.
Building Massively Scalable application with Akka 2.0Building Massively Scalable application with Akka 2.0
Building Massively Scalable application with Akka 2.0
Knoldus Inc.1.1K views
Introduction to Actor Model and Akka by Yung-Lin Ho
Introduction to Actor Model and AkkaIntroduction to Actor Model and Akka
Introduction to Actor Model and Akka
Yung-Lin Ho15.2K views
Akka london scala_user_group by Skills Matter
Akka london scala_user_groupAkka london scala_user_group
Akka london scala_user_group
Skills Matter1.1K views
JavaOne: A tour of (advanced) akka features in 60 minutes [con1706] by Johan Janssen
JavaOne: A tour of (advanced) akka features in 60 minutes [con1706]JavaOne: A tour of (advanced) akka features in 60 minutes [con1706]
JavaOne: A tour of (advanced) akka features in 60 minutes [con1706]
Johan Janssen288 views
A tour of (advanced) Akka features in 40 minutes by Johan Janssen
A tour of (advanced) Akka features in 40 minutesA tour of (advanced) Akka features in 40 minutes
A tour of (advanced) Akka features in 40 minutes
Johan Janssen285 views
Akka Microservices Architecture And Design by Yaroslav Tkachenko
Akka Microservices Architecture And DesignAkka Microservices Architecture And Design
Akka Microservices Architecture And Design
Yaroslav Tkachenko4.6K views
Event Sourcing and beyond with Akka.NET Persistence by Konrad Dusza
Event Sourcing and beyond with Akka.NET PersistenceEvent Sourcing and beyond with Akka.NET Persistence
Event Sourcing and beyond with Akka.NET Persistence
Konrad Dusza427 views
Scaling Web Apps with Akka by Maciej Matyjas
Scaling Web Apps with AkkaScaling Web Apps with Akka
Scaling Web Apps with Akka
Maciej Matyjas5.5K views
Reactive Microservices with JRuby and Docker by John Scattergood
Reactive Microservices with JRuby and DockerReactive Microservices with JRuby and Docker
Reactive Microservices with JRuby and Docker
John Scattergood692 views
Reactive Programming in .Net - actorbased computing with Akka.Net by Sören Stelzer
Reactive Programming in .Net - actorbased computing with Akka.NetReactive Programming in .Net - actorbased computing with Akka.Net
Reactive Programming in .Net - actorbased computing with Akka.Net
Sören Stelzer491 views
Building Stateful Microservices With Akka by Yaroslav Tkachenko
Building Stateful Microservices With AkkaBuilding Stateful Microservices With Akka
Building Stateful Microservices With Akka
Yaroslav Tkachenko1.9K views
GR8Conf 2011: GPars by GR8Conf
GR8Conf 2011: GParsGR8Conf 2011: GPars
GR8Conf 2011: GPars
GR8Conf945 views
Above the clouds: introducing Akka by nartamonov
Above the clouds: introducing AkkaAbove the clouds: introducing Akka
Above the clouds: introducing Akka
nartamonov3K views
Reactive Programming in Akka by DevFest DC
Reactive Programming in AkkaReactive Programming in Akka
Reactive Programming in Akka
DevFest DC 280 views
Reactive programming with akka by Sovon Nath
Reactive programming with akka Reactive programming with akka
Reactive programming with akka
Sovon Nath120 views

More from Sander Mak (@Sander_Mak)

Scalable Application Development @ Picnic by
Scalable Application Development @ PicnicScalable Application Development @ Picnic
Scalable Application Development @ PicnicSander Mak (@Sander_Mak)
239 views20 slides
Coding Your Way to Java 13 by
Coding Your Way to Java 13Coding Your Way to Java 13
Coding Your Way to Java 13Sander Mak (@Sander_Mak)
414 views80 slides
Coding Your Way to Java 12 by
Coding Your Way to Java 12Coding Your Way to Java 12
Coding Your Way to Java 12Sander Mak (@Sander_Mak)
2K views69 slides
Java Modularity: the Year After by
Java Modularity: the Year AfterJava Modularity: the Year After
Java Modularity: the Year AfterSander Mak (@Sander_Mak)
913 views109 slides
Desiging for Modularity with Java 9 by
Desiging for Modularity with Java 9Desiging for Modularity with Java 9
Desiging for Modularity with Java 9Sander Mak (@Sander_Mak)
1.9K views80 slides
Modules or microservices? by
Modules or microservices?Modules or microservices?
Modules or microservices?Sander Mak (@Sander_Mak)
5.9K views117 slides

More from Sander Mak (@Sander_Mak)(20)

Recently uploaded

Java Platform Approach 1.0 - Picnic Meetup by
Java Platform Approach 1.0 - Picnic MeetupJava Platform Approach 1.0 - Picnic Meetup
Java Platform Approach 1.0 - Picnic MeetupRick Ossendrijver
25 views39 slides
Black and White Modern Science Presentation.pptx by
Black and White Modern Science Presentation.pptxBlack and White Modern Science Presentation.pptx
Black and White Modern Science Presentation.pptxmaryamkhalid2916
14 views21 slides
SAP Automation Using Bar Code and FIORI.pdf by
SAP Automation Using Bar Code and FIORI.pdfSAP Automation Using Bar Code and FIORI.pdf
SAP Automation Using Bar Code and FIORI.pdfVirendra Rai, PMP
19 views38 slides
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N... by
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...James Anderson
33 views32 slides
Scaling Knowledge Graph Architectures with AI by
Scaling Knowledge Graph Architectures with AIScaling Knowledge Graph Architectures with AI
Scaling Knowledge Graph Architectures with AIEnterprise Knowledge
24 views15 slides
Transcript: The Details of Description Techniques tips and tangents on altern... by
Transcript: The Details of Description Techniques tips and tangents on altern...Transcript: The Details of Description Techniques tips and tangents on altern...
Transcript: The Details of Description Techniques tips and tangents on altern...BookNet Canada
130 views15 slides

Recently uploaded(20)

Black and White Modern Science Presentation.pptx by maryamkhalid2916
Black and White Modern Science Presentation.pptxBlack and White Modern Science Presentation.pptx
Black and White Modern Science Presentation.pptx
maryamkhalid291614 views
SAP Automation Using Bar Code and FIORI.pdf by Virendra Rai, PMP
SAP Automation Using Bar Code and FIORI.pdfSAP Automation Using Bar Code and FIORI.pdf
SAP Automation Using Bar Code and FIORI.pdf
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N... by James Anderson
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
James Anderson33 views
Transcript: The Details of Description Techniques tips and tangents on altern... by BookNet Canada
Transcript: The Details of Description Techniques tips and tangents on altern...Transcript: The Details of Description Techniques tips and tangents on altern...
Transcript: The Details of Description Techniques tips and tangents on altern...
BookNet Canada130 views
Spesifikasi Lengkap ASUS Vivobook Go 14 by Dot Semarang
Spesifikasi Lengkap ASUS Vivobook Go 14Spesifikasi Lengkap ASUS Vivobook Go 14
Spesifikasi Lengkap ASUS Vivobook Go 14
Dot Semarang35 views
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院 by IttrainingIttraining
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas... by Bernd Ruecker
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
Bernd Ruecker26 views
Igniting Next Level Productivity with AI-Infused Data Integration Workflows by Safe Software
Igniting Next Level Productivity with AI-Infused Data Integration Workflows Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Safe Software225 views
The details of description: Techniques, tips, and tangents on alternative tex... by BookNet Canada
The details of description: Techniques, tips, and tangents on alternative tex...The details of description: Techniques, tips, and tangents on alternative tex...
The details of description: Techniques, tips, and tangents on alternative tex...
BookNet Canada121 views
From chaos to control: Managing migrations and Microsoft 365 with ShareGate! by sammart93
From chaos to control: Managing migrations and Microsoft 365 with ShareGate!From chaos to control: Managing migrations and Microsoft 365 with ShareGate!
From chaos to control: Managing migrations and Microsoft 365 with ShareGate!
sammart939 views
STPI OctaNE CoE Brochure.pdf by madhurjyapb
STPI OctaNE CoE Brochure.pdfSTPI OctaNE CoE Brochure.pdf
STPI OctaNE CoE Brochure.pdf
madhurjyapb12 views
Attacking IoT Devices from a Web Perspective - Linux Day by Simone Onofri
Attacking IoT Devices from a Web Perspective - Linux Day Attacking IoT Devices from a Web Perspective - Linux Day
Attacking IoT Devices from a Web Perspective - Linux Day
Simone Onofri15 views
Empathic Computing: Delivering the Potential of the Metaverse by Mark Billinghurst
Empathic Computing: Delivering  the Potential of the MetaverseEmpathic Computing: Delivering  the Potential of the Metaverse
Empathic Computing: Delivering the Potential of the Metaverse
Mark Billinghurst470 views
Business Analyst Series 2023 - Week 3 Session 5 by DianaGray10
Business Analyst Series 2023 -  Week 3 Session 5Business Analyst Series 2023 -  Week 3 Session 5
Business Analyst Series 2023 - Week 3 Session 5
DianaGray10209 views

Akka (BeJUG)

  • 2. Akka Part of stack Written in Scala With officially supported Java API
  • 3. Akka ‘s premise It’s too hard to write systems that are: Concurrent & Correct Highly scalable Fault-tolerant
  • 4. Akka 2.0 Actors Software Transactional Memory Dataflow concurrency Futures
  • 5. Akka who uses ? traffic management
  • 6. Actors Inspired by : Asynchronous message passing Scale up, scale out Fault-tolerant (‘let it crash’)
  • 7. Actors How to define an actor? ~400 bytes Local state Behavior mailbox
  • 8. Actors How to define an actor? ~400 bytes Create more actors Send messages Modify state Local state Modify behavior Behavior mailbox
  • 9. Actors How to define an actor? class MyFirstActor extends Actor { var total = 0 def receive = { case MyMessage(payload) => println(“Received: “ + payload”) case countMessage: Int => total += countMessage case _ => println("Unknown message") } }
  • 10. Actors Dispatcher: contains executor strategy Local state Event-driven Behavior mailbox
  • 11. Actors and Fork/Join Ping/pong messages (no processing) Improved 48 JSR-166 build ( ?) cores
  • 12. Demo NearestCityActor NearestCityActor NearestCityActor NearestCityActor RoundRobin Result Router ListenerActor Messages with cities Print results
  • 13. Supervision Hierarchical supervision Child actors supervised by parent Trap exceptions and apply recovery Error Kernel pattern Actor 1 create child actor Actor 2 dangerous operation critical state supervise Distinguish scratch and critical state
  • 14. Supervision class GuardianActor extends Actor { def supervisorStrategy = OneForOneStrategy({ case _:CompanyBankruptException => Stop case _:InvalidStateException => Restart case _:ServiceUnavailableException => Resume case _ => Escalate }, maxNrOfRetries = 3, 5.seconds) def receive = { ... } } Actor may implement preRestart & postRestart
  • 15. Remote actors Dispatchers for scale-up, remote actors for scala-out Machine A Machine B actor2 ! SomeMsg Actor 1 Actor 2 Netty, Protobuf Router Actor 3 Actor creation Supervision Remote deploy through config (no code change)
  • 16. Remote actors Creating 10 actors on 2 nodes with a router akka  {    actor  {        deployment  {            /serviceA/aggregation  {                router  =  "round-­‐robin"                nr-­‐of-­‐instances  =  10                target  {                    nodes  =  ["akka://app@10.0.0.2:2552",  "akka://app@10.0.0.3:2552"]                }            }        }    } } Looking up a remote actor val  actor  =        context.actorFor("akka://actorSystemName@10.0.0.1:2552/user/actorName")
  • 17. Blocking Actors lift some ForkJoin restrictions Remoting possible Recursive decomposition optional Fault-tolerant Still, there are restrictions similar to ForkJoin tasks No blocking IO No explicit locking No shared memory writes
  • 18. Async IO Based on composable Futures Serve http mini akka-Spray Consume http async-http-client Persistence hammersmith
  • 19. Async IO Based on Java NIO Akka IO Immutable abstractions on top of: Channels Streams (Iteratee based) Bridges (low-level) async IO and actors
  • 20. Async IO Practical application: JMeter => 1 user, 1 thread Gatling => 1 user, 1 actor + blocking IO + async-http-client = OutOfMemory errors = or clustering necessary time drift in results
  • 21. Async IO Practical application: JMeter => 1 user, 1 thread Gatling => 1 user, 1 actor + blocking IO + async-http-client = OutOfMemory errors = or clustering necessary time drift in results
  • 22. Is that all? Finite State Machine Akka TestKit core Scheduler Event Bus modules
  • 23. Is that all? Typesafe Console Commercial subscription
  • 24. Questions? Code @ bit.ly/bejug-akka