Writing events without restoring persistence actor's state


(Saleh Khazaei) #1

We’re developing an instance messaging platform and we’re using akka-persistence-cassandra to persist our data.

One of the problems we have is huge memory consumption due to too many running actors (of course, we have set the receive timeout to stop idle actors). The main reason behind the actors being up is that due to the nature of persistence actors, every time we want to persist an event, all of the events will be replied for the actor to restore it’s state, and it will wait until reaching receive timeout to stop itself. Also, this behavior leads to too many redundant read queries on Cassandra while the only thing we need to do is to write the new event.

So, we decided to find a solution to persist events without restoring the actor’s state. Is there any solution implemented in akka-persist to solve this problem or should we implement a solution? how do you propose we solve this problem?

Thanks.


(Christopher Batey) #2

Persisting an event without knowing the current state is dangerous in most cases. If you are sure it is safe you can override recovery in the PersistentActor to Recovery.none (https://doc.akka.io/docs/akka/2.5/persistence.html#recovery) or you snapshot to improve the recovery performance.