Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the purpose of stopping actors in Akka?

I have read the Akka docs on fault tolerance & supervision, and I think I totally get them, with one big exception (no pun intended).

Why would you ever want/need to stop a child actor???

The only clue in the docs is:

Closer to the Erlang way is the strategy to just stop children when they fail and then take corrective action in the supervisor...

But to me, stopping a child is the same as saying "don't execute this code any longer", which to me, is effectively the same as deploying new changes to the code which has that actor removed entirely:

  • Every Actor plays some critical role in the actor system
  • To simply stop the actor means that actor currently doesn't have a role any longer, and presumes the system can now somehow (magically) work without it
  • So again, to me, this is no different than refactoring the code to not even have the actor any more, and then deploying those changes

I'm sure I'm just not seeing the forest through the trees on this one, but I just don't see any use cases where I'd have this big complex actor system, where each actor does critical work and then hands it off to the next critical actor, but then I stop an actor, and magically the whole system keeps on working perfectly.

In short: stopping an actor (to me) is like ripping the transmission out of a moving vehicle. How can this ever be a good/desirable thing?!?

like image 494
smeeb Avatar asked Dec 08 '25 00:12

smeeb


2 Answers

The essence of the "error kernel" pattern is to delegate risky operations and protect essential state, it is common to spawn child-actors for one-off operations, and when that operation is completed and its result send off somewhere else, the child-actor or the parent-actor needs to stop it. (otherwise the child-actor will remain active/leak)

like image 84
Viktor Klang Avatar answered Dec 11 '25 17:12

Viktor Klang


If the child actor is doing a longer process that could be terminated safely, such as video coding, or some kind of file transformation and you have to deploy a new build, in that case a terminate sign would be useful to stop running processes gracefully.

like image 27
znurgl Avatar answered Dec 11 '25 16:12

znurgl



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!