Event Sourcing: Snapshotting

In an Event Sourced system, the current state of an aggregate is usually reconstituted from the full history of events. It means that before handling a command we need to do a full read of a single fine-grained stream and transport the events over the network. For a well-designed aggregate, it’s usually not a problem as it’s lifecycle is bounded to a specific time period and the number of events doesn’t grow indefinitely. But what if our design isn’t optimal, or we have some outliers that are requiring thousands of events to be transported every time we want to handle a command?

Read more

Event Sourcing: Aggregates vs Projections

One of the topics that came up a few times (and I noticed quite a number of searches for it) is how the Aggregates and Projections differ or relate to each other. The reason for this confusion is that some parts of the implementation logic are very similar - in particular, the current state of an Aggregate derived from the event log. In this blog post, we will explore the differences and look at some examples.

Read more

Modelling aggregates with "Aggregate Design Canvas"

Designing a good aggregate with the right boundaries and clear responsibilities is not a trivial task. A lot of times when I discuss various design options with people, I learn that they rely on gut feeling or implicit heuristics to guide modelling decisions. In order to make this design process simpler I've decided to create an Aggregate Design Canvas.

Read more

Modelling Aggregates: Invariants vs Corrective Policies

Designing software systems that are aligned with business often leads to compromises and design tradeoffs. It's usually not feasible to model a system in a way that will in 100% reflect the real world.

Understanding business rules is the first step of getting a useful model, but that's not enough. Modelling them as software often leads to discoveries - we realise that it might not be practical, or even possible to enforce some of the rules.

The right thing to do in such a situation is to go back to domain experts and discuss the trade offs we are willing to make. That might mean that we will have to give up on implementing a strongly consistent Invariant and replace or support it with a Corrective Policy.

Read more