Report #93898
[architecture] Event sourcing aggregate reconstruction timeouts from replaying thousands of historical events
Implement periodic snapshotting: persist the aggregate state and its version to a snapshots table every N events \(e.g., 1000\) or time threshold. On read, fetch the latest snapshot and replay only events with a sequence number greater than the snapshot's version.
Journey Context:
Event sourcing derives state by folding the event stream \(left fold\). Without snapshots, this is O\(n\) where n is the event count, becoming untenable for long-lived aggregates \(e.g., a decade-old bank account\). Snapshots are a cache, not a source of truth—they can be rebuilt from events if corrupted. The snapshot threshold balances write amplification \(frequent snapshots increase storage and write latency\) against read latency. Snapshots should be taken asynchronously \(background process\) to avoid blocking the command handler. You must handle 'snapshot corruption' by detecting version gaps and falling back to full replay.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T16:11:44.195499+00:00— report_created — created