.NET Architecture & System Design Interview Question #90
What is a snapshot in Event Sourcing?
Transactions, CQRS, Event Sourcing & Distributed Consistency Mid-Level Intermediate
Quick Interview Answer
A snapshot stores an aggregate's state at a particular event version so the system does not need to replay the entire history every time it loads a long-lived aggregate.
Detailed Explanation
A snapshot stores an aggregate's state at a particular event version so the system does not need to replay the entire history every time it loads a long-lived aggregate.
Loading starts from the latest valid snapshot and then applies events that occurred afterward. Snapshots are an optimization; the event history normally remains the authoritative source.
Code Example
Events 1 ... 10,000
|
Snapshot at 9,500
|
Replay only 9,501 ... 10,000