How to externalize akka sharded actor state to redis or ignite?

131 views Asked by At

I am very new to Akka clustering and working on a proof of concept. In my case i have an actor which is running on a cluster and the actor has state as a Map[String,Any]. So, for any request the actor receives it based on the incoming message it create a new entity actor and the data map. The problem here is the map is in memory right now. Is it possible to store the sharded actor state somewhere in redis or ignite ?

1

There are 1 answers

0
Frederic A. On

You should probably start by having a look at akka-persistence (the persistence module included in akka). The snapshotting part is meant to persist the state directly, but you have to start with the command/event-sourcing part, the snapshotting part being an optional enhancement.

Then you can combine this with automatic passivation of your sharded actors after a certain inactivity timeout.

With the above, you'll have a solution that persists the state of your actors in an external storage system to free up memory, restoring your actor's state whenever they come back to life.

Last step would be to see which storage backends are available for akka-persistence and match your requirements, you can implement your own of course.