简体   繁体   中英

Can I save the state of my entire Actor System in Akka.NET?

I've been reading through and researching a fair bit on Akka.NET and feel that it's a good fit for a very basic online multiplayer game that I will be developing.

I've been particular interested in the Persistence module within Akka.NET. What I would love to be able to do is take a snapshot of my entire Actor system at any point in time and have that snapshot restored at a time of my choosing (essentially a Save/Load mechanic for the game state). This Saving and Loading of Actor persistence appears to happen quite automatically, whereas I would be looking to manually snapshot the current state of the system and restore at a time of my choosing.

Is such a scenario possible with Akka.NET persistence?

Akka.NET persistence uses event sourcing as its way to persist and recreate actor state. It also supports creating snapshots of the full current state, but this should be regarded as a performance optimalisation and cannot be used alone. Also note that persistence works on a per-actor basis. You cannot freeze the whole system into one state.

However, what you can do is the following: you implement persistence, but just never persist any events. Then you send in a message to the top-level actor that says something like "SaveSnapshotRecursive". All actors receiving that message will save a snapshot and forward the message to their children (they should also record in the snapshot the list of their current children). This snapshot store can just be file based if you like that and you can at any moment use it to restore the full state.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM