get-eventually / go-eventually

Idiomatic Domain-driven Design, CQRS and Event Sourcing for Go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add support for Snapshots

ar3s3ru opened this issue · comments

Context and problem statement

Aggregate Roots are typically "small", where the number of Domain Events registered for each AR is in the order of 100-1000.

In such cases, there is no problem rebuilding the state of an AR by the beginning of its Event Stream, as pulling ~1000 events back into the application should still be pretty efficient.

However, there are cases where an AR can record a pretty high number of Domain Events, reaching a point where replaying the Event Stream from the very beginning each time can become a performance bottleneck.

Solution

To alleviate this issue, we can use a Snapshot, which contains the state of the AR at a specific point. Snapshots can be used as a starting point for the AR rehydration to reduce the number of Events that need to be replayed from the Event Stream in the Event Store.