Performance
Sometimes loading Aggregates from large Streams can cause performance problems, especially when individual Streams go beyond hundreds of thousands of Events. There are a couple of simple patterns that could be applied in individual cases to solve this problem:
• Cache Event Streams in server memory, leveraging the fact that Events are immutable once written to an Event Store. While querying the Event Store for any changes, we could supply a version of the last known Event and ask only for those that occurred since then, if any. This can improve performance at the cost of memory consumption.
• Avoid loading and replaying a large portion of an Event Stream by taking a snapshot of each Aggregate instance. This way, while loading any ...
Get Implementing Domain-Driven Design now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.