What is the actor model?
The actor model treats actors as the fundamental unit of computation. Each actor is an isolated entity that:- Processes messages sequentially (one at a time)
- Maintains private state (no shared memory with other actors)
- Communicates exclusively via message passing
Why use actors?
Actors provide a natural model for concurrent and distributed systems:- Encapsulation — State is private; no locks or mutexes needed inside an actor
- Location transparency — You send to a PID; the framework routes locally or remotely
- Fault isolation — A failing actor does not corrupt others; supervision handles recovery
- Scalability — Actors can be distributed across nodes; the cluster manages placement
Core concepts
Actor hierarchy
Every actor lives inside a tree. GoAkt creates guardian actors at startup:- Root — Top of the tree
- System — Parent of internal actors (dead letter, scheduler, etc.)
- User — Parent of all user-spawned actors
Single-threaded execution
GoAkt guarantees that only one goroutine processes messages for a given actor at any time. You never need internal locks to protect actor state. Messages are processed sequentially from the actor’s mailbox (FIFO).The Actor interface
Every actor must implement theActor interface:
Keep actor state in unexported fields. Initialize in
PreStart, not in constructors. The framework guarantees
single-threaded execution per actor, so no locks are needed inside Receive.
Further reading
- Brian Storti: The Actor Model — Short introduction
- Messaging — Tell vs Ask, message types
- Actor Lifecycle — Spawn, stop, state transitions