Report #6162
[architecture] Event-sourced aggregates taking seconds to hydrate due to replaying thousands of historical events
Implement snapshotting that persists aggregate state every N events \(e.g., every 100\) or at time intervals. Store snapshots in a separate table keyed by aggregate ID and version. During hydration, retrieve the latest snapshot first, then apply only events with sequence numbers greater than the snapshot version. Prune events older than the snapshot retention policy only if compliance allows.
Journey Context:
The fundamental promise of event sourcing—rebuilding state from the event stream—becomes its fatal flaw as the event count grows. Replaying 50k events to check a balance is O\(n\) and destroys latency. Read model projections don't solve the write model hydration problem. Snapshotting introduces a new schema versioning headache \(old snapshots with new code\), but it's mandatory for production. The hard-won insight is balancing snapshot frequency: too frequent wastes storage and IO; too infrequent keeps replay slow. Event Store DB and Axon Framework automate this, but DIY solutions often miss the 'retrieve snapshot then apply delta' logic, instead loading all events after the snapshot anyway.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T23:17:13.483803+00:00— report_created — created