2

Is there a Akka stream back-pressure model or something for using akka shardings with persistent actor?

Because I have a problem, I have a akka sharding cluster with persistent actors. (using cassandra as journal plugin).
Sometimes a lot of actors should be created concurrently. (e.g when we want to send a broadcast message to all users.)
and thousands of persistent actors try to recover in a short time (e.g 3.seconds) and in a heavy load cassandra cant responds in a time and a lot of actors fails in recovery for multiple times and never recovers again.

hich9n
  • 1,578
  • 2
  • 15
  • 32

1 Answers1

4

I think what you want is a supervision strategy with exponential backoff. So if the restart (i.e. recovery from the database) fails, it will not try again immediately, but in increasing time intervals, as to not to overload the database. Akka provides this with the BackoffSupervisor.

To use this with Cluster Sharding, you'll have to create an intermediate parent actor for your entities that defines the supervision strategy, see the Cluster Sharding docs (the cluster sharding supervision strategy itself is not pluggable, as explained in this Github issue).

lutzh
  • 4,917
  • 1
  • 18
  • 21