Efficient creation of large number of stateful Actors

My query is on how to efficiently create large number of stateful Actors. For example, a Bank Account Actor which stores balance as its State. As Actor follows Isolated mutability, they can not have a shared object say list of Bank_Account. I see two approaches to create Actors for this usecase;

  1. Create one Actor for each Account. Would not this be inefficient in terms of resource usage?

  2. Create required Actor/s on demand based on the operation and delete them once the operation is completed (say create 2 Actor in case of money_transfer usecase). What is the cost of such creation?


  1. Are there any effificient approaches?
  2. We have Threadpool to reduce the cost of frequent creation and deletion of threads. Is there any similar approaches for Actors?

Somebody else will have a more extensive answer, but check this out: https://doc.akka.io/docs/akka/current/typed/cluster-sharding.html#passivation

Particularly https://doc.akka.io/docs/akka/current/typed/cluster-sharding.html#automatic-passivation

Passivation, in my words, and as I understand it, means that persisted actors are removed from memory when inactive for a certain period, but recreated from the persisted state on demand.

Actors are lightweight and you can have many of them but they need to be stopped when not used any more. Cluster Sharding and passivation is a good solution for this.

Thank you Ignatius and Patrik.