# The Actor Model in 10 Minutes

![rw-book-cover](https://www.brianstorti.com/assets/images/profile-small.png)

## Metadata
- Author: [[brianstorti.com]]
- Full Title: The Actor Model in 10 Minutes
- Category: #articles
- URL: https://www.brianstorti.com/the-actor-model/
- Archive: https://web-archive.alecodes.page/bookmarks?bf=1&search=&title=The%20Actor%20Model%20in%2010%20Minutes
> [!tldr]
> The actor model is a conceptual model for concurrent computation that uses actors as the primitive unit of computation. Actors receive messages and perform computation based on them, similar to objects in object-oriented languages. Actors are isolated from each other and maintain a private state. Messages are sent asynchronously and stored in an actor's mailbox until processed. Actors can create more actors, send messages to other actors, and designate how to handle the next message. The actor model also allows for fault tolerance and distribution across multiple machines.

## Highlights
An actor is the primitive unit of computation. It’s the *thing* that receives a message and does some kind of computation based on it. [View Highlight](https://read.readwise.io/read/01j918hcacc07w4axvgt59x8zq))

actors are completely isolated from each other and they will never share memory. It’s also worth noting that an actor can maintain a private state that can never be changed directly by another actor. [View Highlight](https://read.readwise.io/read/01j918j9h6jqm35fdy1vqcfpvd))

In the actor model everything is an actor and they need to have addresses so one actor can send a message to another. [View Highlight](https://read.readwise.io/read/01j918ke4asb17p1z7nt58d46v))

multiple actors can run at the same time, an actor will process a given message sequentially. [View Highlight](https://read.readwise.io/read/01j918nf2daeb5my4gfz7vq4vy))

Messages are sent asynchronously to an actor, that needs to store them somewhere while it’s processing another message. The mailbox is the place where these messages are stored. [View Highlight](https://read.readwise.io/read/01j918p5c4xp37ry1q48rk46p7))

![](https://www.brianstorti.com/assets/images/actors.png) [View Highlight](https://read.readwise.io/read/01j918m33wqavsptrvx0tt7pen))

When an actor receives a message, it can do one of these 3 things:
• Create more actors
• Send messages to other actors
• Designate what to do with the next message [View Highlight](https://read.readwise.io/read/01j918qs9pm600m7ywrjcwjwmb))

“Designating what to do with the next message” basically means defining how this state will look like for the next message it receives. Or, more clearly, it’s how actors mutate state. [View Highlight](https://read.readwise.io/read/01j918r1sd8f8ajq9n0b44atyr))

What `Erlang` does is simply letting it crash, but make this critical code be supervised by someone whose only responsibility is to know what to do when this crash happens (like resetting this unit of code to a stable state), and what makes it all possible is the actor model. [View Highlight](https://read.readwise.io/read/01j918v4a749ra9wqtaag6xrt4))

This makes it possible to create systems that “self heal”, meaning that if an actor gets to an exceptional state and crashes, by whatever reason, a supervisor can do something about it to try to put it in a consistent state again [View Highlight](https://read.readwise.io/read/01j918xtyxjak1pwdav830pd8a))

Another interesting aspect of the actor model is that it doesn’t matter if the actor that I’m sending a message to is running locally or in another node. [View Highlight](https://read.readwise.io/read/01j9192dk4wf5rj9ccpzhpfb29))

