Recreating actors after system restart

If I want to restart my actor system (for example to deploy a new version of the code) am I responsible for recreating the actors when it starts back up? Or is there a way to get Akka to remember the previous state and recreate it for me?

Thanks!

If you use Akka Cluster Sharding, the remember-entities feature stores what entities were started in a database or such, and makes sure they are restarted.

When not using sharding there is nothing out of the box, you will need implement some way to persist the fact that some actor was started (and any potential parameters it needs to be passed be created) and have a parent that can load that data on start and start children accordingly.

Note that you will likely also have to sort that the actors themselves persist their state so that they can continue from the state they had when they stopped, for example using Akka Persistence Event Sourcing or Akka Persistence Durable State

In a clustered app it can also be possible to keep state across rolling updates using Akka Distributed Data however that will normally not survive a cold restart, shutting down and then restarting the entire cluster.

Some other things that are good to think about when wanting to do rolling updates with a clustered Akka app can be found here: Rolling Updates • Akka Documentation

3 Likes