peter vlugter - goto...
TRANSCRIPT
![Page 2: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/2.jpg)
It’s hard tobuild systems
that are
highlyconcurrent
![Page 3: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/3.jpg)
middleware for building awesome concurrent and distributed applications
Akka
![Page 4: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/4.jpg)
Simpler
![Page 5: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/5.jpg)
Actorsobjects that send and receive messages
STMtransactions in shared memory
Dataflowdeterministic directed flow of data
![Page 6: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/6.jpg)
![Page 7: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/7.jpg)
Actor Model
A Universal Modular ACTOR Formalismfor Artificial Intelligence
Carl Hewitt, Peter Bishop, Richard Steiger
1973
Actor Model
A Universal Modular ACTOR Formalismfor Artificial Intelligence
Carl Hewitt, Peter Bishop, Richard Steiger
1973
![Page 8: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/8.jpg)
Actor Model
A Universal Modular ACTOR Formalismfor Artificial Intelligence
Carl Hewitt, Peter Bishop, Richard Steiger
1973
Actor Model
Physics
Functional programmingfrom Lisp
Message passingfrom Simula and Smalltalk
![Page 9: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/9.jpg)
It’s actors all the way down
Until you reach turtles
![Page 10: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/10.jpg)
What is an actor?
![Page 11: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/11.jpg)
An actor is a computational entity
that responds to messages
![Page 12: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/12.jpg)
sendsend messages to other actors
createcreate new actors
becomedefine behaviour for the next message
![Page 13: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/13.jpg)
![Page 14: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/14.jpg)
Akka Actors
![Page 15: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/15.jpg)
actorOf[SomeActor](“name”)
returns an ActorRef, not an Actor
Actor reference
![Page 16: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/16.jpg)
actor ! message
asynchronous, fire and forget
Send
![Page 17: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/17.jpg)
actor tell message
non-symbolic method name
Send
![Page 18: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/18.jpg)
def receive = { case i: Int => ... case s: String => ... case _ => ...}
match with a partial function
Receive
![Page 19: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/19.jpg)
class Counter extends Actor { var count = 0
def receive = { case Tick => count += 1 }}
Receive
![Page 20: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/20.jpg)
sender ! message
reference to the sender
Reply
![Page 21: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/21.jpg)
class Counter extends Actor { var count = 0
def receive = { case Tick => count += 1 case Get => sender ! count }}
Reply
![Page 22: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/22.jpg)
class Counter extends Actor { var count = 0
def receive = { case Tick => count += 1 case SendTo(actor) => actor ! count }}
pass actor references in messages
Actor-passing
![Page 23: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/23.jpg)
become { case Message => ...}
define the next receive behaviour
Hot swap
![Page 24: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/24.jpg)
unbecome()
revert to the previous behaviour
Hot swap
![Page 25: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/25.jpg)
class Counter extends Actor { def receive = count(0)
def count(i: Int): Receive = { case Tick => become(count(i + 1)) case Get => sender ! i }}
recursive behaviour containing state
Behaviour and state
![Page 26: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/26.jpg)
Example
![Page 27: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/27.jpg)
Async work
HTTP request,received by a front end,
given to a worker,response to the client
![Page 28: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/28.jpg)
class Worker extends Actor { def receive = { case Work(args) => val result = perform(args) sender ! result }}
worker simply replies with a result
Worker
![Page 29: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/29.jpg)
class FrontEnd extends Actor { def receive = { case Request(params) => val worker: ActorRef = ... worker ! Work(params) // response? }}
how is the response handled?
Front end
![Page 30: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/30.jpg)
front end actor receives request
Async workfront end worker
request
![Page 31: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/31.jpg)
create an actor to handle this response
Async workfront end worker
request
responder
![Page 32: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/32.jpg)
send work with reply-to as responder
Async workfront end worker
responder
![Page 33: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/33.jpg)
result through responder
Async workfront end worker
responder
response
![Page 34: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/34.jpg)
class Responder(request: Request) extends Actor { def receive = { case result => request completeWith result self.stop() }}
one-off actor for handling the result
Responder
![Page 35: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/35.jpg)
class FrontEnd extends Actor { def receive = { case Request(params) => val worker: ActorRef = ... implicit val replyTo = context.actorOf(new Responder(request)) worker ! Work(params) }}
create a responder to handle the result
Front end
![Page 36: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/36.jpg)
![Page 37: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/37.jpg)
Futures
![Page 38: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/38.jpg)
val future = actor ? message
ask an actor for something
Ask
![Page 39: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/39.jpg)
val future = actor ask message
non-symbolic method name
Ask
![Page 40: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/40.jpg)
future.get
blocks while waiting for the result
Future
![Page 41: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/41.jpg)
future onComplete { _.value.get match { case Left(problem) => ... case Right(result) => ... }}
add an on-complete callback
onComplete
![Page 42: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/42.jpg)
future onResult { ... }
future onException { ... }
future onTimeout { ... }
three types of completion
Callbacks
![Page 43: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/43.jpg)
val f1 = Future { “hello” }
val f2 = f1 map { _.length }
transform in the future
Mapping
![Page 44: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/44.jpg)
val f = for { a <- Future(40) b <- Future(2)} yield a + b
compose with for comprehensions
Composing
![Page 45: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/45.jpg)
val x, y, z = Promise[Int]()
flow { z << x() + y()}
flow { x << 40 }flow { y << 2 }
compose with dataflow
Dataflow
![Page 46: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/46.jpg)
![Page 47: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/47.jpg)
STM
![Page 48: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/48.jpg)
def transfer(from: Ref[Int], to: Ref[Int], amount: Int) = atomic { from alter (_ - amount) to alter (_ + amount) }
classic bank account example
STM
![Page 49: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/49.jpg)
atomic { if (from.get < amount) retry from alter (_ - amount) to alter (_ + amount)}
explicitly retrying for conditions
STM retry
![Page 50: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/50.jpg)
atomic { // ... deferred { launcher ! FireMissiles }}
callback run when successful
Side-effects
![Page 51: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/51.jpg)
![Page 52: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/52.jpg)
Actor tree
b
a
d
c
ef
g
![Page 53: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/53.jpg)
path to actor c is /a/b/c
Actor path
b
a
d
c
ef
g
![Page 54: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/54.jpg)
system.actorFor(“/a/b/c”)
find an actor using its path
Find actors
![Page 55: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/55.jpg)
Supervision
![Page 56: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/56.jpg)
Erlang’s
9 nines
![Page 57: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/57.jpg)
![Page 58: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/58.jpg)
the parent actor supervises the child
Supervisor
![Page 59: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/59.jpg)
resumeignore and continue as normal
restartcreate a fresh instance
stopterminate the actor permanently
escalatelet the supervisor above decide
![Page 60: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/60.jpg)
case _: ArithmeticException => Resumecase _: ActorInitException => Stopcase _: Exception => Restartcase _ => Escalate
Throwable => Action
Fault handler
![Page 61: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/61.jpg)
only the child that fails is affected
One for One
![Page 62: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/62.jpg)
one child fails, all children are affected
All for One
![Page 63: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/63.jpg)
entire sub-tree is affected
Escalate
![Page 64: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/64.jpg)
top-level guardians isolate and protect
Guardians
user system temp
![Page 65: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/65.jpg)
![Page 66: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/66.jpg)
Same code
Distributed
![Page 67: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/67.jpg)
akka.actor.deployment { /path/to/actor { remote { nodes = ["somewhere:2552"] } }}
configure an actor as remote
Remote actor
![Page 68: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/68.jpg)
![Page 69: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/69.jpg)
akka.actor.deployment { /path/to/actor { router = "round-robin" nr-of-instances = 5 remote { nodes = ["wallace:2552", "gromit:2552", ...] } }}
several instances, round robin routing
Routers
![Page 70: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/70.jpg)
![Page 71: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/71.jpg)
Cluster
Decentralised peer-to-peer
Automatic failover and adaptive rebalancing
![Page 72: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/72.jpg)
![Page 73: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/73.jpg)
Gossip protocol
inspired by
Amazon’s Dynamo
Basho’s Riak
![Page 74: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/74.jpg)
Add-ons
![Page 75: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/75.jpg)
IntegrationCamel, Spring, ZeroMQ, AMQP
HTTPPlay framework, REST APIs
Durable mailboxesFile system, Redis, MongoDB, Zookeeper
![Page 76: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/76.jpg)
MicrokernelStand-alone deployment
TestKitTesting toolkit for Akka actors
ConsoleTrace, monitor, manage, provision
![Page 77: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/77.jpg)
![Page 78: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/78.jpg)
Simpler to build systems that are
highly concurrent
truly scalable
fault tolerant
![Page 79: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/79.jpg)
Learn more
http://akka.io
http://typesafe.com
![Page 80: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/80.jpg)
Thank you!
![Page 81: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/81.jpg)
?
![Page 82: Peter Vlugter - GOTO Conferencegotocon.com/dl/jaoo-melbourne-2011/slides/akka-yow-2.pdfpeter.vlugter@typesafe.com It’s hard to build systems that are highly concurrent middleware](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec9882fcd21621731505a88/html5/thumbnails/82.jpg)