Actor Flashcards
What is an Actor in the Actor Model?
An independent computational unit with:
Private state (never shared)
A mailbox (for receiving messages)
Behavior (how it processes messages)
Key Idea: Actors communicate only via asynchronous messages.
What are the 3 core rules of the Actor Model?
No shared state (actors encapsulate data)
Message-passing only (no direct method calls)
Process one message at a time (no locks needed)
How do Actors communicate?
By sending immutable messages asynchronously.
Messages are stored in the receiver’s mailbox (queue).
Each actor processes messages sequentially.
Example (Pseudocode):
python
actor ! {“type”: “greet”, “text”: “Hello”} # Send message
Why use Actors for concurrency?
No locks: Each actor runs independently.
Scalability: Distributed across threads/machines.
Fault tolerance: Isolated failures (like Erlang’s “let it crash”).
How do Actors differ from OOP objects?
Actors OOP Objects
Communicate via messages Call methods directly
No shared state Shared state possible
Async by default Often sync/blocking
How do Actors handle failures?
Supervision hierarchies: Parent actors monitor children.
Strategies: Restart, resume, or escalate failures.
Isolation: One actor crashing doesn’t break others.
Example: Erlang’s “let it crash” philosophy.
What is location transparency in Actors?
Actors can communicate the same way whether they’re:
On the same thread
On different machines
(No code changes needed!)
Name 3 Actor Model frameworks/languages.
Erlang/Elixir (built-in Actors)
Akka (JVM, Scala/Java)
Orleans (.NET)
When should you use the Actor Model?
High concurrency (e.g., chat servers)
Distributed systems (e.g., microservices)
Fault-tolerant systems (e.g., telecoms)
What are limitations of the Actor Model?
Debugging complexity (async flows)
Message overhead (serialization costs)
No guaranteed delivery (unless built explicitly)
What are the key lifecycle stages of an Actor?
Created
Running (processing messages)
Paused (waiting)
Terminated