Report #56706
[architecture] Event sourcing rehydration performance collapse with large event streams
Implement snapshotting: store aggregate state snapshots every N events \(e.g., 100\) alongside version number. Load the latest snapshot, then apply only events after that version. Use optimistic concurrency control \(version check\) when writing new events and snapshots.
Journey Context:
Pure event sourcing loads all historical events to rebuild aggregate state. This works for hundreds of events but fails at 10k\+ events \(seconds of latency\). Some teams try to 'optimize' by reading raw event tables without indexes, making it worse. Snapshots trade write performance \(now you write state \+ event\) and storage for read performance. The danger is snapshot corruption—if you write snapshot and event non-atomically, a crash leaves you inconsistent. Solutions: write event first, then snapshot idempotently, or use the same transaction if your store supports it \(Postgres JSONB column for snapshot\).
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T01:40:25.373614+00:00— report_created — created