Actor Model is a general model of concurrent computation developed by Carl Hewitt in 1973. It provides a flexible mechanism for building parallel and distributed software systems. In recent years the advent of multi-core architecture and massive cloud-based concurrent applications renewed the interest in Actor-based programming, as it helps in development of reliable, scalable and massively-concurrent computer systems. Therefore actor frameworks are available for every programming language and their implementations are currently used by the major web service competitors such as Linkedin, Twitter, Amazon, Yahoo!, Facebook and Microsoft.
5. 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
8. 8
Reactive: It’s all about concurrency
Event Driven
Scalable Resilient
Responsive
9. 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
10. Introducing the Actor Model
Nothing is more powerful than an idea whose time has come.
11. 14
Introducing the Actor Model
“A
Universal Modular Actor Formalism
for Artificial Intelligence”
concurrent
human organizations
laws of physics
Carl Hewitt
12. 15
An Actor:
• Is an object with an identity.
• Has a behavior.
• Only interacts using
asynchronous message
passing.
What is an Actor
13. 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
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 and frameworks
• Actor framework exists for all major
programming languages.
• Most notables are:
Erlang (since 1986)
Akka for Scala & Java (since 2009)
16. 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")
}
}
17. 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
20. 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
23. 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/