Is there documentation of the lifecycle of a ReceivePersistentActor? I'm interested in the circumstances a persistent actor is killed/stopped/dehydrated to allocate resources for other actors. Our application creates a lot of persistent actors and I'm seeing that some are Terminated. Is there a timeframe that a persistent actor has to be "inactive" before it is terminated? What other conditions are considered?
Asked
Active
Viewed 99 times
1 Answers
0
Actors are only terminated automatically when:
- Their parent is shut down or
- If you're running Akka.Cluster.Sharding, actors that are created via the sharding system will be automatically passivated after two minutes of inactivity: https://getakka.net/articles/clustering/cluster-sharding.html#passivation
Normal persistent actors don't shut down on their own - they'll hang around so long as the ActorSystem
and their parent actor are live.

Aaronontheweb
- 8,224
- 6
- 32
- 61
-
Are they ever terminated to free up resources? The parent is receiving the "Terminated" message, and I figured it's because of resource allocation since we are spinning up thousands of child actors at once. – Brian Sain Aug 13 '21 at 19:51
-
No, Akka.NET won't automatically terminate actors outside of those two use cases I mentioned. Programming an actor to terminate after a long idle period using `ReceiveTimeout` is something that many users do frequently though for that very purpose. – Aaronontheweb Aug 13 '21 at 20:28
-
1It's worth noting that JVM Akka has added (as of 2.6.18, presumably driven by Akka Serverless) support for pluggable automatic passivation strategies (the other one now shipping with Akka being a fixed limit and then evict the least recently used). Presumably similar support could eventually be used in Akka.NET. – Levi Ramsey Jan 05 '22 at 11:36