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;
Create one Actor for each Account. Would not this be inefficient in terms of resource usage?
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?
- Are there any effificient approaches?
- We have Threadpool to reduce the cost of frequent creation and deletion of threads. Is there any similar approaches for Actors?