BranislavLazic / akka-cqrs-activator

Issue tracker PoC application written in Scala (Akka) and JavaScript (React) that demonstrates event sourcing and CQRS
Apache License 2.0
32 stars 2 forks source link

Use recovery from snapshots in IssueRepository #8

Closed BranislavLazic closed 6 years ago

BranislavLazic commented 6 years ago
smulikHakipod commented 6 years ago

Hey. I am trying to write a large scale application based on your design. I am hitting some bottlenecks I am trying to resolve and maybe you can help. In your example in forwardToIssueRepository you create an actor for each Issue being accessed in the system. Those actors are always there in memory while the system is alive. In large scale this would take a lot of memory until it reaches exhaustion, while probably most of the actors are not being used for a long of time. I am for example thinking of limiting the amount of live Issue actors for 100,000, and use akka setReceiveTimeout in order to passive actors. How would you solve it?

BranislavLazic commented 6 years ago

Passivation sounds quite good. You could simply terminate actors after certain period of inactivity. In this case, e.g. I'd definitely terminate an actor after the issue is deleted since there's no reason to keep it in memory anymore. Keep in mind that this is an example where the the number of actors shouldn't be that high. In case you need really high number of actors in memory, you can also consider cluster sharding.