NinekoTheCat

NinekoTheCat

Why isn't the actor model used in the wild?

I am learning elixir, and I am looking everywhere but for some reason the… actor model isn’t used at all?

There’s no other processes aside from… endpoints and repos??

here there’s a bit more child processes but like… why isn’t there more??

Most Liked

dimitarvp

dimitarvp

You are making a very classic mistake here – you are trying to find a simple formula.

There is no simple formula though.

The actor model (Erlang processes) is about being able to model runtime entities. Which entities, how many, and when are they spawned depends on your business requirements.

Actors are just one more tool in your belt.

This article might help a little bit: The Erlangelist - To spawn, or not to spawn?

But again, don’t expect a simple formula.

That’s part of the entire answer – and here the partial answer is “yes”.

But there’s also the aspect of “I want to control access to a resource” (you already mentioned locking) and “I want to make sure this entity receives messages only one by one, sequentially” (what GenServers do).

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

Actors in Elixir generally map to runtime subcomponents of the system, not business entities. So for example when using phoenix channels or live view every connected page is an actor that manages messages in and data out, but then the business logic processing on that data favors functional data patterns.

dimitarvp

dimitarvp

Well, roughly – yes, that’s one factor.

But there’s more to it. So imagine your app is for example about reserving hours to doctors. And in your controller you have to consult a 3rd party API (for example Microsoft Calendar).

  • If you want to give people immediate confirmation or rejection, you do the 3rd party API call (a network request) inside your controller function without spawning a process, so your customers will have to wait in the browser until that request completes.
  • If you opt for customers to never wait you will spawn this 3rd party network API call in a new process and immediately return something to the customers like “We have requested reservation of the hours of this doctor. You should receive an email within a few minutes telling you if the hours are free.”

As you can see, this is not about the technical capabilities, this is about what the business wants.

Where Next?

Popular in Questions Top

sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
New
marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
tduccuong
Hi, is there any work on GUI with Elixir, that is similar to Electron/Javascript? My idea is to bundle Phoenix and BEAM into a single se...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
earth10
Hi, I’m just starting to build a side-project with Elixir and Phoenix and doing some basic test with Elixir alone. What strikes me is th...
New
vegabook
I’m brand new to Phoenix and I have stripped one of the demo applications to the bone. I just want to get an svg up on the screen. Here i...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New

Other popular topics Top

Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
johnnyicon
Hi all, I’ve just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I’m trying to use Postgres...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement