When snapshots refresh
- After a configurable number of events (
snapshot_threshold). - When an operator calls
dbx snapshots create <aggregate> <id>. - When schemas request it via
snapshot_threshold(auto-snapshots fire after appends hit that count).
dbx aggregate verify when you need a fresh Merkle root without creating a snapshot.
Storage layout
Snapshots live alongside aggregate state in RocksDB and include the aggregate id, version, payload, Merkle root, timestamps, and optional comments. Compression keeps them small, so retaining several generations is usually cheap.Tuning cadence
- High-churn aggregates (carts, sessions): lower
snapshot_thresholdto 5–10 events so plugins read fresh state quickly. - Low-churn aggregates (accounts, ledgers): keep the threshold higher (100+) to minimise writes.
schemas.json):
dbx config --snapshot-threshold <count> and override per aggregate with dbx schema create ... --snapshot-threshold <count> or dbx schema alter ....
Using snapshots downstream
Plugins can request snapshots instead of replaying events when they only need current state (payload_mode state-only). Use this for read models that want current state (search indexes, caches) without caring about the entire history. If a downstream system falls behind, replay snapshots plus events from the last acknowledged offset.