Haufe #msaday - The Actor model: an alternative approach to concurrency By Lorenzo Nicora
Dec. 1, 2016•0 likes•509 views
Download to read offline
Report
Technology
A short introduction to the Actor model, as an alternative approach to concurrent programming from Lorezon Nicora's talk at Haufe Microservices Architecture Day.
Haufe #msaday - The Actor model: an alternative approach to concurrency By Lorenzo Nicora
1. The Actor Model
1
An alternative approach to concurrency
Lorenzo Nicora
Senior Consultant @ OpenCredo
@nicusX
https://opencredo.com/author/lorenzo/
2. ✓ (1973) Carl Hewitt: “A Universal Modular Actor Formalism for Artificial Intelligence”
2
A bit of History…
1973
2009
✓ (2009) Akka toolkit, Scala/Java
✓ (1986) Ericsson: Erlang
Lorenzo Nicora Actor Model
3. According to Alan Kay,
author of Smalltalk
and inventor of the “Object-Orientation”:
3
The original idea of Object
An “Object”
✓ Is the basic unit of object-oriented system
✓ Has its own state
✓ Communicate with others
by sending and receiving messages*
* in Java, C++, C# (derived from Simula, not Smalltalk)
Objects interact by invoking methods
1980
Lorenzo Nicora Actor Model
4. An “Actor”
is a computational entity that,
in response to a message it receives,
can concurrently:
a) Send a finite number of messages to other actors
b) Create a finite number of new actors
c) Designate the behaviour to be used for the next message
it receives. [implies a state]
4
The Actor
Actor
Actor
Actor
Mailbox Mailbox
Mailbox
Lorenzo Nicora Actor Model
5. Actors interacts
only by messaging
Actors react to
messages
5
Actors are Reactive
Lorenzo Nicora Actor Model
6. An Actor handles one message a time
Never concurrently
An Actor has a state
State cannot be modified from outside the actor
6
Thread-safe
An Actor is inherently thread-safe
No Lock/Synchronisation on State
Lorenzo Nicora Actor Model
8. 8
Supervision
Failure Handling
• If a Child throws an Exception, the Supervisor get notified
• Supervision Strategy: e.g. relaunch, abandon…
Failure is always handled consistently
Parent = Supervisor
Lorenzo Nicora Actor Model
22. 22
Conclusions
Actor model:
an alternative approach to concurrency
Actors, Threads
+ Business logic implementation +
inherently thread-safe
- A new programming paradigm -
to learn
Lorenzo Nicora Actor Model