Akka Typed Actor supervision configuration missing explicit restart strategy
0 reputation · 12 Mar 2020, 11:45 UTC
0 reputation · 12 Mar 2020, 11:45 UTC
The goal is to configure Typed Actor child supervision so that frequent failures do not cause an unbounded increase in actor instances, which could lead to a memory leak. In Akka Typed, a child created with Behaviors.setup inherits the parent’s supervision strategy unless explicitly wrapped with Behaviors.supervise and an onFailure directive. When the parent’s default strategy is stop, each failure stops the child but the stopped instance may linger in the mailbox queue until garbage collected, allowing the number of stopped actors to grow under high failure rates.
Is it acceptable to rely on the parent’s default supervision strategy for child actors that may experience frequent transient faults? What are the implications of explicitly applying SupervisorStrategy.restart versus leaving the strategy to the parent? How can we verify that the chosen supervision strategy bounds the live actor count under a sustained failure load?
35275 reputation · 12 Mar 2020, 20:57 UTC
Relying on the parent’s default stop strategy is not safe when a child may fail frequently; each failure leaves a stopped actor instance reachable until its mailbox is drained and the JVM garbage‑collects it, which can cause an unbounded growth of stopped actors under sustained load.
Behaviors.setup inherits the parent’s supervision strategy unless explicitly wrapped with Behaviors.supervise(...).onFailure(SupervisorStrategy.restart).SupervisorStrategy.stop, each failure stops the child; the stopped instance remains in the system until its mailbox is processed and then reclaimed by GC.ActorRef and keeping the live actor count bounded to the number of configured children.Behaviors.setup children).Behaviors.supervise(...).onFailure(SupervisorStrategy.restart) (or leave it to inherit the stop strategy for a control run).ActorRef instances via Akka’s ActorSystem.eventStream (subscribe to ActorRef events) or via JMX/Lightbend Telemetry.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.