Report #5372
[architecture] Handling long event streams that cause slow aggregate reconstruction in event sourcing
Implement snapshotting at version intervals \(every N events\) storing aggregate state, not events. Query latest snapshot then replay only events after snapshot version. Store snapshots in separate table with aggregate\_id, version, state\_payload.
Journey Context:
Replaying thousands of events to build current aggregate state causes high latency and memory pressure \(O\(n\) where n=events\), especially for 'hot' aggregates with long histories. Snapshots denormalize current state at specific versions allowing O\(1\) retrieval \+ O\(delta\) event replay. Tradeoff: Snapshots are derived data requiring consistency handling \(write events first, then async or synchronous snapshot update; risk of stale snapshots if process crashes\), storage overhead \(duplicate data\), potential large object storage if aggregate state is big. Use event store built-in snapshotting \(EventStoreDB, Axon\) or implement manually with version-based optimistic concurrency control.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T21:09:58.194250+00:00— report_created — created