☼
⌃
☰

Actor Model

Table of Contents

Actor Model

The Actor Model is a conceptual model for concurrent computation that treats "actors" as the universal primitives of a system. It provides a high-level abstraction for building concurrent and distributed systems, avoiding common pitfalls associated with shared state and manual lock management.

Core Principles

  • Actors: An actor is a lightweight, independent process that encapsulates its own private state and behavior. It is the fundamental unit of computation.
  • Message Passing: Actors communicate exclusively by sending and receiving asynchronous messages. They do not share memory. Each actor has a "mailbox" to queue incoming messages.
  • Isolation: An actor's state is completely private and cannot be accessed or modified directly by any other actor. This inherent isolation eliminates the need for locks and prevents race conditions by design.

Actor Actions

In response to receiving a message, an actor can perform three fundamental actions:

  • Create new actors.
  • Send messages to other actors (including itself).
  • Change its own internal state, which will affect its behavior for the next message it processes.

Benefits

  • Simplified Concurrency: By avoiding shared state and locks, the model simplifies the development of concurrent applications, preventing issues like deadlocks and race conditions.
  • Scalability & Distribution: The message-passing nature of actors allows systems to scale easily, as actors can be distributed across multiple cores or even different machines on a network without changing the fundamental design.
  • Fault Tolerance: The isolation of actors means that the failure of one actor does not cascade and bring down the entire system. This is the foundation of the "let it crash" philosophy seen in languages like Erlang and Elixir.

Implementations

The Actor Model is the foundational concurrency model for languages like Erlang and Elixir, which leverage it to build highly resilient and scalable systems.