1 minute read

Intro

Following a roadmap [1] to study about web application using Rust, I find Actix framework. On the homepage, it says it’s an “actor” framework. I have no idea what the “actor” means. According to Wikipedia [2], the actor model is a mathematical model of concurrent control. Let’s try to dig it more and way to understand.

Actor model

Pure function

Have you heard about a pure function? I faced this term when I tried to learn Scala language. The pure function returns the same result if inputs are the same, and it creates no side-effect. Since a snippet of source code produces the same value, it is possible to use it in a distributed system. We can get whatever we expect without a careful design of the concurrency control because there is no global-level modification by default.

Erlang

supervisor_and_actor

In the real world, Erlang is one famous language that implements the actor model. [3] I remembered the first time I met the Elixir. The philosophy of Elixir is “let it crash!”. It is not familiar with the other languages. In Elixir, I need to design one supervisor that can handle an invalid scenario. Using the invalid handler, we can relaunch the app when it faces an invalid situation. It means it can be self-healed from an error.

Actor

I understand that “Actor” works like the pure function with more functions. It has a message queue and processes the message in a FIFO(First In First Out) way. The actor does three operations;

  • Create more Actors
  • Send messages to other Actors
  • Designate what to do with the next message

Outro

In this short post, I try to explain what the actor model is. For me, the name of it is close to the “executor”. While I’m writing this article, I can look back on Scala and Elixir. Thank you, and please leave messages if I’m wrong.

Reference

[1] https://github.com/anshulrgoyal/rust-web-developer-roadmap

[2] https://en.wikipedia.org/wiki/Actor_model

[3] https://www.brianstorti.com/the-actor-model/

Leave a comment