← Lessons

quiz vs the machine

Gold1400

Concurrency

The Actor Model Deep Dive

State hides inside actors and travels only as messages.

5 min read · core · beat Gold to climb

One mailbox, one thread of control

An actor is an isolated unit that owns private state and a mailbox. It processes one message at a time, in arrival order, so its own state never sees concurrent access. There are no shared variables to lock because nothing is shared.

What an actor can do

On each message an actor may:

  • Send messages to other actors it knows.
  • Create new actors.
  • Change its own behavior for the next message.

Because state lives behind the mailbox, the only way to affect an actor is to send it a message. This turns synchronization into ordinary queuing.

Supervision

Actors form trees. A supervisor watches its children and decides what to do when one crashes: restart it, stop it, or escalate. This let it crash philosophy keeps faults local instead of corrupting shared memory.

Trade offs

Single message processing removes races but caps a single actor throughput, so hot actors become bottlenecks. The fix is to shard work across many actors.

Key idea

An actor owns private state and processes one mailbox message at a time, so concurrency reduces to message passing instead of locking.

Check yourself

Answer to earn rating on the learn ladder.

1. Why does an actor never need a lock on its own state?

2. What is the role of a supervisor actor?

3. What limits a single actor's throughput?