Report #27080
[architecture] Event sourcing aggregate rebuild time growing linearly with event count, causing >5s cold start for large aggregates
Implement snapshotting every N events \(e.g., 100\) or time-based: store aggregate state \+ version; replay only events after snapshot version; keep snapshots immutable \(append-only\)
Journey Context:
Event sourcing without snapshots requires replaying the entire event stream to reconstruct aggregate state. An aggregate with 100,000 events must load and apply all 100,000 events from the event store, deserialize them, and fold them into state—a process taking seconds or minutes and growing unboundedly with the aggregate's lifetime. This makes the system slower as it succeeds more. Snapshotting breaks this O\(n\) complexity by storing periodic copies of the aggregate state. The system loads the most recent snapshot \(O\(1\)\) and replays only events occurring after that snapshot \(bounded to N, typically 100-1000\). Critical implementation details: \(1\) Snapshots must be immutable and append-only; updating a snapshot destroys the audit trail and risks race conditions. \(2\) Snapshots are a cache, not the source of truth—if corrupted, delete and rebuild from events. \(3\) Use optimistic concurrency control: snapshot includes version number; if new events arrived during snapshot creation, discard and retry. \(4\) Snapshot granularity is a tradeoff: frequent snapshots speed recovery but increase storage and write amplification.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T23:51:14.747882+00:00— report_created — created