Why Event Sourcing? Part 3 - The Core Benefits of Event Sourcing

Stephen Tung  |  20 June 2024

This is the final part of a 3 part series on "Why Event Sourcing". Find Part 1 here and Part 2 here.. If you want to be notified, sign up to our newsletter! If you're totally new to Event Sourcing, it might be a good idea to start here  with our Beginner's Guide.

Introduction

In the previous part, we have looked at the key concepts of event sourcing and what makes it unique.

In this final part, we will explain what the core benefits of event sourcing are and how it can help make complex and core business data easier to manage.

Core Benefit of Event Sourcing #1: Discover Unlimited Insight across Space and Time

The flexibility of a state transition database allows for the transformation of data into unique insight on your core business data. This makes it simpler to understand complex systems and make more informed decisions.

It also improves data quality and integrity since the completeness and auditability of the database can verify and any downstream data copy. This makes it simpler to detect data that is out of sync.

This is especially important in a data-driven world where big data analytics and machine learning are vital to increase your competitive advantage.

The insight can reveal patterns, trends, and anomalies that would be hard to detect in traditional systems.

Insight from Transformation across Space

With a granular record of events, event sourcing can build different forms of the data for different audiences.

For a credit card company, where all transactions are recorded, different departments can construct their own customized reports to gain extra insight.

For example:

12_Table

Insights from Transformation across Time

With a log of historical events, event sourcing can construct views from different timelines in the present, past, and future.

The present state is usually rebuilt by replaying through all the relevant events in log.

The past on the other hand can be rebuilt by replaying events from the beginning up to a certain point in time. This can be done using temporal queries:

13_Table

The future can be with forecast with machine learning and data analytics when there are enough events in your database.

Core Benefit of Event Sourcing #2: Easier Eventual Consistency to Decouple and Optimize Complex Systems

Event sourcing makes it easier for developers to implement eventually consistent operations.

This makes it easier to help decouple your systems into systems that are optimized for each use case.

And makes it easier for your complex system to be more adaptable, making it less painful and costly to change.

14_Making system more adaptable

Let’s see how this is achieved.

Tight Coupling with the Solution Stack

As mentioned in part 1, traditional databases tend to lead to tightly coupled systems due to its lack of support for eventual consistency.

As a result you may often find your stack completely dependent on your database and schema.

But what most developers don’t realize, is that this dependency is not limited to just the technical stack. The problem is extended to the “business” stack as well together into a solution stack.

solution stack

Problems with a Tightly Coupled and Overburdened Solution Stack

While this form of coupling usually doesn't pose a problem for simple applications, it can become an issue as the number of use cases increases. As the stack takes on more responsibilities, it can become overburdened. When the same stack is optimized for many use cases, issues may begin to surface across the layer.

16_Table

Better Eventual Consistency Support with State Transition Database

Compared to Traditional databases, Event sourcing and the state transition database provides great eventual consistency support.

Since its event log has the auditability to verify whether copies of data sent downstream are correct, it makes eventually consistent operations much easier to implement:

17_Table

And this makes it simpler to decouple data from the complex solution stack.

Building Optimized Solution Stacks with Event Sourcing

With event sourcing, you can build a state that is not tied to any existing data schema or database. You can use relational, document, or even a graph database for this.

In fact, because of this, you can build an entire solution stack that is optimized for one specific use case.

solution stack (1)

Decoupling Complex Systems with Optimized Solution Stacks per Use Case

Instead of relying on the same stack for every use case, you can now reconstruct a highly optimized stack for each use case.

19_Optimized Stacks

This decouples the source of truth from the other systems effectively, and allows developers to change them without huge impact.

For example, I can project my events to a database that’s completely optimized for high read performance. This can be an in-memory database like Redis to store a copy of the data as cache. And this can use a simplified data schema that contains the minimal fields required for fast read operation.

The same can be done for another stack that is optimized for data analytics. Perhaps in this case I would utilize an OLAP cube that lets business analysts to slice data in multiple dimensions quickly. This cube can be self-hosted on premise to protect the data from the public cloud.

With this, the source of truth is not overburdened with all kinds of use cases, and can be more free to distribute its responsibilities to other systems instead.

This effectively decouples the source of truth from them, and allows developers to change the stack without causing a ripple effect on the whole system.

And this makes the whole system more adaptable to change which keeps the cost of managing core business data manageable even as complexity increases.

20_Cost Complexity Graph

Summary

In this series, we have explained that:

  • Core business data is expensive to manage because systems that uses it are often interdependent and complex.
  • Traditional databases are popular, but it is not a great choice for your core data especially when it has to be distributed far and wide.
  • Traditional databases often lead to overburdened and tightly coupled systems since it is designed for transactionally consistent operations.
  • Event sourcing and event store on the other hand is designed for eventual consistency, which makes it easy to decouple complex systems.
  • Event sourcing reduces the burden on the database and allows optimized stacks to be built for each individual use case
  • Event sourcing can also transform your data to virtually unlimited perspectives across space and time.
  • This makes event sourcing the premier application pattern for ever-changing and complex systems.

Watch the webinar

If you enjoyed this blog series, watch Stephen's webinar, Why EventStoreDB Decouples your Distributed Ball of Mud: A Beginner's Guideto learn more about the concepts discussed and how state transition database EventStoreDB can support you. 

 


Photo of Stephen Tung

Stephen Tung Stephen has been a software practitioner and leader focused on simplifying and tackling the heart of complex business problems. He discovered DDD/CQRS/ES 15 years ago and has never looked back since. He's the father of three, living in Hong Kong, and enjoys to zen out when there is a moment.