Search code examples
akka

How to scale up or out persistent actors for better throughput?


Is it possible to use persistent actor with router such as to scale out? If you have elasticity with persistent actor you have a problem with your event sourcing.

Hence I wonder how to scale up or out persistent actors for better throughput?


Solution

  • The question is a bit too open to answer directly, though generally there's two things you can do for starters:

    For improving a Persistent Actor's throughput there's techniques you can use inside it already, i.e. using persistAsync which batches up updates into one batch sent to the Journal.

    PersistentActors can be easily scaled-out by using them together with ClusterSharding which allows to start actors for given ids (and shard ids) on independent nodes - which sales out the load to those.

    Of course for tuning raw throughput of message persisting, you definitely must pick a fast serialization format and configure it as explained in the docs on schema evolution.

    Lastly, but very importantly, you should pick a Journal implementation which will scale to your needs. Cassandra is a popular choice, however you'll need to run at least 3 nodes for it to make sense I'd say.