Skip to main content

Snapshot

Cached aggregate state at a point in time. Snapshots optimize replay by avoiding the need to apply all historical events.

When to Snapshot

By default, Angzarr snapshots every 16 events. This balances:

  • Storage cost (more snapshots = more storage)
  • Replay performance (fewer events to apply)

Snapshot Retention Policies

PolicyBehaviorUse Case
RETENTION_DEFAULTPersist every 16 eventsNormal operation
RETENTION_PERSISTKeep indefinitelyBusiness milestones
RETENTION_TRANSIENTDelete when newer writtenTemporary checkpoints

Structure

A snapshot contains:

  • Serialized aggregate state
  • Sequence number at snapshot time
  • Timestamp
  • Retention policy

Trade-offs

Without snapshots:

  • Replay all events from beginning
  • Slower aggregate load
  • No storage overhead

With snapshots:

  • Replay only events after snapshot
  • Faster aggregate load
  • Additional storage for snapshot data