Hi guys
I’ve got a persistent actor model that is modelling an aggregate root. The event journal for this model is getting quite large (often over 10k events per actor) which can result in quite slow recovery times. As I understand it there are two ways to solve this: Snapshotting or splitting into more actors.
I’m a little bit afraid of snapshotting since the domain model is not serializable, so I’m afraid of possible data loss converting to and from a serializable model. Hence I’m looking at the possibility of splitting up into different actors.
For context, the shape of my domain model is something like this:
case class Foo {
// lots of properties
bar: List[Bar]
}
so my idea is to create separate persistent actors for each bar
in the list. This list can contain from 1 to 2000 entities.
Constraints and complexities
The top level Foo
actor will handle some commands that change the state of multiple bar
entities. Since these are now split into different actors I’m afraid of message delivery guarantees in that scenario, i.e some bar
actors might not receive a command. One possible strategy would be to contain that state in the Foo
actor, i.e. no commands would need to be routed to be multiple bar
entities, instead i’d contain that state in the Foo
actor. I don’t really like that strategy since the state in question is inherently a part of the bar
model.
So I guess my question is given this domain and constraints, would you go with snapshotting or splitting into different persistent actors, and if so, is it possible to guarantee deliveries from Foo
to bar
?