Snapshot Questions

Hi everyone. Collected some questions / concerns about snapshots while working with them…

At high level view I’m implementing billing system for users. User is my aggregate and it can have two main
types of operations: automatic charge / replenishment and manual charge / replenishment. Automatic type of events are
very frequent, manual not. Ideally for me to have two types of snapshots: default aggregate snapshot and custom, which
saves periodically groups of automatic events and creates new event based on such batches: total charged for one hour and total income for one hour for example.
First snapshot is good for fast retrieval of current aggregate state - current balance, second for displaying some sort of billing history without need to scan through
all automatic events.

  1. First problem I’ve encountered is that it is not possible to have several trigger definitions and thus different snapshots per aggregate. I guess I can implement
    some chain of snapshoters, just curios if I’m missing something ?
  2. Is it possible to initialize projections and tracking tokens from latest default aggregate snapshot and not scanning through all of the events?
  3. Didn’t find AggregateSnapshot event in axon dashboard search menu. Found it in swagger api. Is it ok to use snapshot events like any other events or they are
    for internal use only.
  4. What is the lifecycle of Trigger instance which is created by Trigger Definition? I guess it is coupled to aggregate, but for how long does it live. There is no shutdown or destroy
    methods in it. I’ve created custom time based Trigger Definition and it has a per hour event publisher that is subscribed from all created triggers. Running for some period
    of time will have lots of stale subscribers (not active users). Is there some good way to notify of trigger being destroyed ? Or probably there is better way to achieve time based snapshot creation ?
  5. Are there any checks when creating new snapshot for events between latest snapshot and current ? So that new snapshot is created for only active aggregate (Speaking about default snapshot)

Thanks !

After doing some tests decided not to use multiple snapshot types. Having second snapshotter that is saving only part of events, which
could be derived, looks now redundant for me.
My main is question now is whether I understand the initial purpose of snapshots.
Is it for faster loading current aggregate state from eventstore or could it also be used for faster projections replay ?
Initially I hoped for some way of having fixed interval of events, say for the last year, which are “active” and start from snapshot which was created a year ago.
This will give more predictable amount of time needed to replay all events by projection from the beginning of the time, without actually starting from the beginning of time.

Since the snapshot is the serialzed state of an aggregate,
it can't represent another view/state and is therefore not initially useable for speeding up replays.

Interesting would be to push this current marks further.
Maybe someting like a makro event, consisting of the information of many events before could be used instead...
I haven't tried this before....

Yep, this what I was trying initially to achieve with custom snapshoter. But after a while thought that having such makro
event will be redundant and not so beneficial as still event processors have to go from the beginning, filtering all events out but makro events.
Better and easier would be batching them as much as possible. But still, having some fixed period of events from aggregated state will make me
feel much safer :slight_smile:
Probably will give a try to event migration and look how it goes. Otherwise don’t think this will be very frequent task to perform full replay and when
there will be a need to do so, segmented tracking processors (possibly on multiple nodes) should be enough.