Actor Model and Reactive Manifesto
Angelo Simone Scotto
Cluster Reply
The Reactive Manifesto
You can never solve a problem on the level on which it was created.
3
New tools for a new era
4
users
load
failure
events
Reactive Applications
Reactive Manifesto
5
“In karate, there is an image that's used to define the position of
perfect readiness: "mind like water" Imagine throwing a pebble
into a still pond. How does the water respond? The answer is,
totally appropriately to the force and mass of the input; then it
returns to calm. It doesn't overreact or underreact”
Not just for software
6
Hardware is going reactive too.
TrueNorth neurosynaptic chip, IBM Research
7
Reactive Traits
Event Driven
Scalable Resilient
Responsive
8
Reactive: It’s all about concurrency
Event Driven
Scalable Resilient
Responsive
9
• Usually, code we write is thought to be executed sequentially.
• We tend to use shared state and synchronization mechanism
such as locks to face concurrent executions.
• Sharing and Locking exposes us to new set of problems:
Deadlock, Livelock, Starvation, False Sharing, …
• «…our intellectual powers are rather geared to master static
relations and that our powers to visualize processes evolving
in time are relatively poorly developed..» E. Dijkstra, 1968
• «There are severe limits in how much can be kept in mind at
once (about 3–5 items)” N. Cowan, 2010
• «It’s the damn humans. The critters simply can’t think in
parallel» G. Bracha, 2014
Concurrency IS hard
Introducing the Actor Model
Nothing is more powerful than an idea whose time has come.
14
Introducing the Actor Model
“A
Universal Modular Actor Formalism
for Artificial Intelligence”
concurrent
human organizations
laws of physics
Carl Hewitt
15
An Actor:
• Is an object with an identity.
• Has a behavior.
• Only interacts using
asynchronous message
passing.
What is an Actor
17
An Actor:
• Is an object with an identity.
• Has a behavior.
• Only interacts using
asynchronous message
passing.
What is an Actor
What
time is it?
12:37
18
An Actor can:
• send a finite number of
messages to other actors;
• create a finite number of new
actors;
• designate the behavior to be
used for the next message it
receives.
What can an actor do ?
What
time is it?
12:37
19
Actor libraries and frameworks
• Actor framework exists for all major
programming languages.
• Most notables are:
Erlang (since 1986)
Akka for Scala & Java (since 2009)
20
Show me some code !
// A simple actor
class Echo extends Actor {
def receive = {
case value: String =>
println(value)
case _ => println("ERROR:
received unknown message")
}
}
22
class AtomicInteger extends Actor {
var innerValue = 0;
def receive = {
case Initialize(value) => innerValue = value;
case Increment(value) => innerValue += value;
sender ! innerValue;
case Decrement(value) => innerValue -= value;
sender ! innerValue;
}
}
Single actors are synchronous
23
Hewitt example of actor system
US Department of State Organization chart
24
As they most probably are…
25
Just for reactive software?
OOP messaging, local
retention protection hiding of
state-process
Actor model retained
the good features of the
object idea
Alan Kay
30
Good enough for them? Good enough for you!
Erlang Use Cases
31
Good enough for them? Good enough for you!
Akka Use Cases
Reactive Manifesto: http://www.reactivemanifesto.org/
Principle of Reactive Programming: https://www.coursera.org/course/reactive
Akka website: http://akka.io/
Erlang: http://www.erlang.org/
Actor Model Implementations: http://en.wikipedia.org/wiki/Actor_model#Actor_libraries_and_frameworks
Hewitt, Meijer and Szyperski: The Actor Model: https://www.youtube.com/watch?v=7erJ1DV_Tlo
Reactive Design Patterns: http://www.manning.com/kuhn/
Reactive Enterprise with Actor Model: http://www.amazon.com/Reactive-Enterprise-Actor-Model-Application/dp/0133846830
How Twitter is scaling: https://waimingmok.wordpress.com/2009/06/27/how-twitter-is-scaling/
Microsoft Orleans & Halo 4: http://caitiem.com/2014/04/03/orleans-preview-halo-4/
Linkedin Use Case: http://downloads.typesafe.com/website/casestudies/LinkedIn-Case-Study-v1.3.pdf
Facebook Use Case: https://www.facebook.com/note.php?note_id=14218138919
Yahoo! Use Case: http://www.drdobbs.com/parallel/using-erlang-to-build-reliable-fault-tol/220600332
Amazon SimpleDB: https://gigaom.com/2007/12/14/amazon-web-services-launches-simpledb-beta/
Thanks
Angelo Simone Scotto
a.scotto@reply.eu

Actor Model & Reactive Manifesto

  • 1.
    Actor Model andReactive Manifesto Angelo Simone Scotto Cluster Reply
  • 2.
    The Reactive Manifesto Youcan never solve a problem on the level on which it was created.
  • 3.
    3 New tools fora new era
  • 4.
  • 5.
    5 “In karate, thereis an image that's used to define the position of perfect readiness: "mind like water" Imagine throwing a pebble into a still pond. How does the water respond? The answer is, totally appropriately to the force and mass of the input; then it returns to calm. It doesn't overreact or underreact” Not just for software
  • 6.
    6 Hardware is goingreactive too. TrueNorth neurosynaptic chip, IBM Research
  • 7.
  • 8.
    8 Reactive: It’s allabout concurrency Event Driven Scalable Resilient Responsive
  • 9.
    9 • Usually, codewe write is thought to be executed sequentially. • We tend to use shared state and synchronization mechanism such as locks to face concurrent executions. • Sharing and Locking exposes us to new set of problems: Deadlock, Livelock, Starvation, False Sharing, … • «…our intellectual powers are rather geared to master static relations and that our powers to visualize processes evolving in time are relatively poorly developed..» E. Dijkstra, 1968 • «There are severe limits in how much can be kept in mind at once (about 3–5 items)” N. Cowan, 2010 • «It’s the damn humans. The critters simply can’t think in parallel» G. Bracha, 2014 Concurrency IS hard
  • 10.
    Introducing the ActorModel Nothing is more powerful than an idea whose time has come.
  • 11.
    14 Introducing the ActorModel “A Universal Modular Actor Formalism for Artificial Intelligence” concurrent human organizations laws of physics Carl Hewitt
  • 12.
    15 An Actor: • Isan object with an identity. • Has a behavior. • Only interacts using asynchronous message passing. What is an Actor
  • 13.
    17 An Actor: • Isan object with an identity. • Has a behavior. • Only interacts using asynchronous message passing. What is an Actor What time is it? 12:37
  • 14.
    18 An Actor can: •send a finite number of messages to other actors; • create a finite number of new actors; • designate the behavior to be used for the next message it receives. What can an actor do ? What time is it? 12:37
  • 15.
    19 Actor libraries andframeworks • Actor framework exists for all major programming languages. • Most notables are: Erlang (since 1986) Akka for Scala & Java (since 2009)
  • 16.
    20 Show me somecode ! // A simple actor class Echo extends Actor { def receive = { case value: String => println(value) case _ => println("ERROR: received unknown message") } }
  • 17.
    22 class AtomicInteger extendsActor { var innerValue = 0; def receive = { case Initialize(value) => innerValue = value; case Increment(value) => innerValue += value; sender ! innerValue; case Decrement(value) => innerValue -= value; sender ! innerValue; } } Single actors are synchronous
  • 18.
    23 Hewitt example ofactor system US Department of State Organization chart
  • 19.
    24 As they mostprobably are…
  • 20.
    25 Just for reactivesoftware? OOP messaging, local retention protection hiding of state-process Actor model retained the good features of the object idea Alan Kay
  • 21.
    30 Good enough forthem? Good enough for you! Erlang Use Cases
  • 22.
    31 Good enough forthem? Good enough for you! Akka Use Cases
  • 23.
    Reactive Manifesto: http://www.reactivemanifesto.org/ Principleof Reactive Programming: https://www.coursera.org/course/reactive Akka website: http://akka.io/ Erlang: http://www.erlang.org/ Actor Model Implementations: http://en.wikipedia.org/wiki/Actor_model#Actor_libraries_and_frameworks Hewitt, Meijer and Szyperski: The Actor Model: https://www.youtube.com/watch?v=7erJ1DV_Tlo Reactive Design Patterns: http://www.manning.com/kuhn/ Reactive Enterprise with Actor Model: http://www.amazon.com/Reactive-Enterprise-Actor-Model-Application/dp/0133846830 How Twitter is scaling: https://waimingmok.wordpress.com/2009/06/27/how-twitter-is-scaling/ Microsoft Orleans & Halo 4: http://caitiem.com/2014/04/03/orleans-preview-halo-4/ Linkedin Use Case: http://downloads.typesafe.com/website/casestudies/LinkedIn-Case-Study-v1.3.pdf Facebook Use Case: https://www.facebook.com/note.php?note_id=14218138919 Yahoo! Use Case: http://www.drdobbs.com/parallel/using-erlang-to-build-reliable-fault-tol/220600332 Amazon SimpleDB: https://gigaom.com/2007/12/14/amazon-web-services-launches-simpledb-beta/
  • 24.