Event Sourcing is a way of creating systems based on event processing. It is a real “buzzword” in the IT industry and a solution that brings many benefits, for example:
Event Sourcing is inextricably linked to many facts and myths, which we would like to clarify and debunk today. All this to show you that Event Sourcing is not as bad as it seems. Let’s get started.
Event Sourcing is not difficult. It is just different. The basis for understanding and modeling the world here are the events that take place in it, and that affects both objects and relations between them. The emphasis here is on understanding business processes. Event Sourcing, therefore, requires a change in thinking and looking from a different perspective.
Business processes also involve “storytelling”. Therefore, it is a good idea to model them as events, because they’re a good reflection of the business process. It is not only a very interesting idea but above all and contrary to popular opinion, a practical one because it allows for maximum simplification of project communication. By relying on events and storytelling, Event Sourcing is simply closer to the real world. Proof? AddedElementToBasket, Accepted Order, IssuedProformaInvoice, Paid, IssuedInvoice, SentOrder. You could not report this sequence of events in a simpler way.
Both Event Sourcing, Domain-Driven Design (DDD), and CQRS focus on understanding business processes and modeling them as faithfully as possible in our software. Thanks to their application, IT systems work better and are easier to maintain. All of the abovementioned methodologies are perfectly compatible with each other, but what is crucial, their combined use is not obligatory. It falls into the category of “nice to have” rather than “must-have”.
Event Sourcing is not linked to a specific way of storing data. The key to understanding it is that the event log is the source of truth. Only the detailed description of events (referred to in point 3) will allow us to obtain current user data. We apply events one by one, from the oldest to the newest one. This process is called aggregation. The resulting state of the object is called projection. Each event can be saved as a row in the “Events” table, and the projection as a row of events in a standard relational table. Separation of the write model from the read model guarantees more optimization possibilities and logical separation. Two databases are unnecessary for all this – yes, you can use them, but it is not required at all. Just like using Mongo for this purpose.
Eventual Consistency is a guarantee that if we have made any changes, sooner or later, they will be applied. We do not know when exactly, but we do know that it will happen. Event Sourcing, in theory, requires Eventual Consistency, just like any other storage. However, events can also be stored in a relational database, so contrary to popular opinion, we do not need Eventual Consistency at all. What is more, if we don’t need to send these events further (e.g. to other services/modules), we also don’t need to use event buses such as the already mentioned Kafka or RabbitMQ.
Event Sourcing is as efficient as the storage it has underneath. What is more, it has 2 of basic assumptions related to storage:
Thanks to these assumptions, storage can be optimized for a situation where we never do “random record updates”. That allows the event table to work faster, because:
That is why Event Sourcing should not only be not slower but can be even faster than traditional solutions.
Event Sourcing is not childishly simple, but which software is not difficult to maintain? Probably only the one that has not reached the production stage. The problems of migration and data consistency in distributed systems are complicated, but they do not get any simpler when using classic/relative solutions. In systems based on events, they simply come to light sooner.
As you can see – Event Sourcing has many advantages, but, like everything else, it also has its limitations and some characteristic issues you need to keep in mind, depending on the specifics of your particular project. This approach has its supporters and opponents. It can bring many benefits when you use it wisely.
You can obtain more information about Event Sourcing from Oskar Dudycz. We also recommend visiting his GitHub profile.
The full version of the summary of pros and cons of Event Sourcing published here is available from: https://www.szkola-event-sourcing.pl/
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
|cookielawinfo-checbox-analytics||11 months||This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".|
|cookielawinfo-checbox-functional||11 months||The cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".|
|cookielawinfo-checbox-others||11 months||This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.|
|cookielawinfo-checkbox-necessary||11 months||This cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".|
|cookielawinfo-checkbox-performance||11 months||This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".|
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.