Passivation

Actors can be passivated when they are idle after some period of time. Passivated actors(including descendants) are removed from the actor system to free-up resources. When cluster mode is enabled, passivated actors are removed from the entire cluster.

Passivation is crucial in large-scale or distributed systems to:

  • Avoid memory/resource leaks.

  • Clean up unused actors.

  • Keep actor lifecycles predictable.

  • Balance load over time.

GoAkt introduces a flexible and pluggable actor passivation mechanism through the WithPassivationStrategy option. This gives developers fine-grained control over how and when inactive or overloaded actors are automatically passivated to free up system resources.

Passivation Strategies

GoAkt comes with the following passivation strategies:

  • Time-Based Passivation: This strategy automatically passivates (i.e., stops) an actor if it has not received any messages within a configurable time duration. This is the default strategy with two minutes duration.

  • Message Count-Based Passivation: This strategy passivates an actor after processing a specific number of messages.

Runtime Control

Passivation can be dynamically paused or resumed at runtime using built-in system messages:

This feature is useful for workflows that require uninterrupted actor activity for a period of time (e.g., during long transactions or event replay).

Last updated