开发者

Benefits of Ncqrs snapshots?

In preparation of a future application design, I've started some investigations on CQRS-style applications and especially Ncqrs.

While most concepts are quite clear, I'm a bit confused by the concept of a snapshot.

I can see why rebuilding an object from its events can be highly resource-consuming, but as the denormalizer will build the read model with the latest state of the entity (or actually the latest values required for a view), why bother with the c开发者_如何转开发oncept of rebuilding the object from snapshots?

Am I right to think such scenarios occur only sporadically and on-demand, mostly after upgrading a version or debugging?

If not, what would be good situations for taking a snapshot?


I have to admit I'm not a big user of event sourcing (or at least, I don't take advantage of it to its fullest extent), but snapshotting helps with the performance of your system when rebuilding the aggregate. Instead of rebuilding all events from time 0, you only need to rebuild back to the last snapshot. So if you have a high number of events in your system and having your event sourcing rebuild your aggregate is starting to affect performance of your command side, you may consider using snapshots.

Check out notes from a Greg Young DDD/CQRS class he taught last year or so; it may give you some ideas of where he's coming from regarding snapshots.

Hope this helps. Good luck!


Snapshots are useful when your aggregate roots have a large number of events (1000+ perhaps?). But something to consider is that in most scenarios your aggregate are short lived and therefore have a small number of events; in which case snapshots can be seen as early optimisation; which isn't necessary a good thing.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜