Catalog
concept#Product#Delivery#Event Sourcing

Event Sourcing

Event Sourcing is an architectural approach where changes to a system are stored as a sequence of events.

Event Sourcing is an architectural approach that allows tracking the state of a system by storing events.
Established
Medium

Classification

  • Medium
  • Technical
  • Architectural
  • Intermediate

Technical context

Databases for storing eventsMessaging systems for event transmissionMonitoring tools for event tracking

Principles & goals

Events are immutable.The state is reconstructed from events.Events are the source of truth.
Build
Domain, Team

Use cases & scenarios

Compromises

  • Mismanagement of events can lead to inconsistencies.
  • Events can be difficult to debug.
  • Excessive storage can lead to high costs.
  • Define events clearly and precisely.
  • Process events in the correct order.
  • Regularly review the event architecture.

I/O & resources

  • Events that change the state
  • Event handlers for processing
  • Persistent storage for events
  • Updated states based on events
  • History of events
  • Audit logs for compliance

Description

Event Sourcing is an architectural approach that allows tracking the state of a system by storing events. Instead of directly storing the current state, all changes are recorded as events. This enables a complete history of changes and facilitates restoring states at a specific point in time.

  • Complete traceability of changes.
  • Easier restoration of states.
  • Better support for audits and compliance.

  • Complexity in managing events.
  • Potential performance issues with large data volumes.
  • Requires a shift in data architecture thinking.

  • Number of Stored Events

    The total number of events stored in the system.

  • Average Recovery Time

    The average time taken to restore a state from events.

  • Event Processing Time

    The time taken to process an event.

Bank Application

A banking application that stores all transactions as events to ensure a complete history of account movements.

E-Commerce Platform

An e-commerce platform that stores orders and payments as events to track order status.

Content Management System

A CMS that stores changes to content as events to make the history of changes traceable.

1

Define the events to be stored.

2

Implement the event handlers.

3

Set up the persistent storage.

⚠️ Technical debt & bottlenecks

  • Insufficient infrastructure for events.
  • Lack of documentation for events.
  • Missing tests for event handlers.
Event ManagementData ConsistencyScalability
  • Using events as temporary data.
  • Not storing events correctly.
  • Not using events for audits.
  • Assuming that events are easy to manage.
  • Believing that all events are equally important.
  • Underestimating the complexity of event processing.
Knowledge of event-driven architectureExperience with data persistenceAbility to analyze event data
Event-Driven ArchitectureMicroservices ArchitectureData Persistence Strategies
  • Events must be immutable.
  • Events must be processed in the correct order.
  • Technical infrastructure must be in place.