5CS022 Lecture 3
5CS022 Lecture 3
Lecture 3
The Actor Model
Why Actor Model?
But fear not, there are great alternatives out there and today I want to
show you one of them: The actor model.
What is the Actor Model?
Properties of an actor
It’s important to understand that, although multiple actors can run at the
same time, an actor will process a given message sequentially.
what happens when an actor receives a
message
Actor behavior and state
supervisor
Supervisor fixes problem 27
Supervisor actor delegates tasks to 28
worker actors
Worker actors perform tasks asynchronously 29
Actors and Scaling 30
● With limited number of CPU cores and limited memory, there will
be limited number of threads available.
● In an asynchronous
system, workers only
occupy desks when they
have something to do
Actor Clusters 40
● There are a number of strategies available both at the actor level and
at the actor system level.
● Actors that create other actors are supervisors, and for error handling
supervisors are notified when a worker hits a problem, and there are
four common recovery steps:
○ Ignore the error and let the worker resume processing
● When a node fails, the sentinel actors are notified via an actor terminated
message
Akka
Framework
Akka
getContext().getSystem().actorOf(Props.create(ActorB.cla
ss));
Akka Actor life cycle