Snapshots structure tends to change quite often. Each new event or change to how the event is applied or interpreted may change the snapshot schema - e.g. Initially in the Order snapshot, you were keeping just the product items count, as it was enough for the business logic. Still, now you’d like to keep the collection of product items). Now you need to reapply the events and old snapshot becomes obsolete.
Of course, you can keep the “schema version” in the snapshot and ignore the events with older “schema version” than the most recent. Still, in my opinion, this is much more complicated than just storing single, the most recent snapshot in the separate stream. If you put the $maxCount
condition on the snapshot stream, then what you need is to get a snapshot and read all events that happened after the revision stored in the snapshot. If you store the new snapshot version, then the old one will be “replaced”.
The perspective of what’s easier and what does not depend on the view, so if you see that as more straightforward, then it’s okay - it’ll work. You can always try both solutions doing smaller PoC and see what suits your case better.
Regarding having all the needed information after storing snapshot - it depends on what you’re doing with events and what information they carry. If they’re as in your example OrderCreated
or OrderUpdated
- so upsert-like then yes, the snapshot will be enough.
However, if you have more granular, domain events like OrderInitiated
, OrderConfirmed
, ProductItemAddedToOrder
then it may be more complex. Suppose you’re using them to trigger some business operation or update projections. Having just a snapshot instead of a series of such event will remove some of the business information. You won’t be able to get the value if you archive old events. So for that case, I’d suggest putting new events in the new stream publishing the event with a link to the old stream. Then projection can handle all events in case of the need to rebuild them.
There is one more aspect - the size of the storage and performance - if you keep snapshots in the same stream, and you’re doing snapshot, e.g. one per three events. Then for 10 000 events in your stream, you have 3000 snapshots more. If you use separate stream, then you can have a single snapshot event.
Short living streams is not based on the inner workings of Event Store. It’s a general best-practice that’s commonly suggested in all event sourcing solutions. Read more in my blog post: https://event-driven.io/en/how_to_do_event_versioning/.
@Vlad_Andronache did my explanation help?