Can Event-Driven Architecture make Software Design Easier? (with Bobby Calderwood)
Jan 3, 2024
auto_awesome
Experienced architect Bobby Calderwood discusses event-driven architecture and the advantages of thinking about software from an event-based perspective. They explore event sourcing, its definition, and its value in various domains including finance and analytics. The conversation also covers the tech stack associated with event-driven architecture, the relationship between event sourcing and functional programming, and the concept of event modeling in system design.
Event sourcing provides a historical record of system events, enabling better process improvement and system integration.
Implementing event sourcing involves technological choices such as using an immutable log and consistent query language.
Optimistic concurrency control is a solution for handling concurrency in event sourcing, ensuring decisions are based on the latest information.
Deep dives
Approaches to Problem Solving
There are different approaches to problem solving through computer programming. One approach is object orientation, where problems are seen as a series of objects with behaviors that interact with each other to find solutions. Another approach is procedural, where complex problems are broken down into smaller, simple problems to be solved using predefined recipes. These approaches shape the way software is written and the tools used for problem solving.
Introduction to Event Sourcing
Event sourcing is a way of looking at software design that focuses on capturing and storing the sequence of events in a system. The system state is derived from these events, which allows for deriving new insights, performing analytics, and enabling better process improvement. Event sourcing provides a historical record of what has happened in the system, giving a clear understanding of cause and effect. It also allows for integrating systems and training AI agents by leveraging the event data. Event sourcing offers value in various domains, including analytics, process improvement, and system integration.
Technological Choices for Event Sourcing
Implementing event sourcing involves considering technological choices such as using an immutable log to store events, ensuring a consistent query language, implementing support for optimistic concurrency control, and indexing events based on streams, subjects, and temporal aspects. While functional programming can be beneficial for event sourcing, it is not a requirement. Event sourcing can be implemented using various technologies, including files on disk, relational databases, or specialized event store databases. The focus should be on capturing events, maintaining immutability, and providing consistent and efficient query capabilities.
Event sourcing and optimistic concurrency control
Event sourcing is a powerful technique where events are captured and stored as the source of truth for an application's state. It allows for a system to be rebuilt at any point in time by replaying the events. One challenge in event sourcing is handling concurrency. Optimistic concurrency control provides a solution by allowing the system to check if the event stream has moved on from a certain point before committing a write. This ensures that decisions are based on the latest information and avoids issues such as double-charging a credit card or overwriting concurrent edits to a document.
Building event stores and the importance of indexes
Event stores are the fundamental component of event sourcing systems. They function as a write-ahead log of events and can be combined with indexes to enable efficient querying. Different event store systems, such as Event Store DB and Evident DB, offer features like fine-grain streams that allow filtering events for specific entities. Indexes can be custom-defined or provided by the system, and they play a crucial role in optimizing performance and enabling fast queries. By designing indexes that match specific business requirements, developers can support a wide range of use cases, including user-defined projections and materialized views.
This week’s guest describes Event Sourcing as, “all I’m going to use for the rest of my career.” But what is Event Sourcing? How should we think about it, and how does it encourage us to think about writing software?
In this episode we take a close look at systems designed around the idea of Events, with guest Bobby Calderwood. Bobby’s been designing (and helping others design) event based architectures for many years, and enthusiastically recommends it not only as a system-design technique, but as a way of solving business problems faster and more reliably.
During this discussion we look at the various ways of defining event systems, what tools we need to implement them, and the advantages of thinking about software from an event-based perspective. Along the way we discuss everything from Clojure, Bitemporality & Datomic to Kafka and more traditional databases - all in the service of capturing real-world events and building simple systems around them.