Wiki: An Abridged Guide to Event Sourcing

For agents: Markdown version · Wiki index · Explore

Written by an LLM from machine transcripts. It can contain errors. Check the transcript before you quote it.

Summary

The speaker presents an introductory guide to event sourcing as an architectural alternative to traditional CRUD models. Using a real-world web builder product example, the talk explores how event sourcing stores immutable facts rather than mutable state, enabling better auditing, scalability, and historical tracking. The audience learns the core principles of event sourcing, CQRS separation of reads and writes, and the trade-offs involved in adopting these patterns. Ultimately, listeners discover how shifting from immediate consistency to tunable consistency can solve complex production challenges.

Key points

  • 4:29 Traditional CRUD applications rely on mutable state and a single authoritative database source of truth, which easily leads to data loss and invalid states.
  • 8:44 Event sourcing is based on CQRS and the principle that performing database updates should not involve destroying historical data.
  • 16:01 Event sourcing treats business entities not as a static snapshot, but as a sequence of immutable events from which the current state can be calculated.
  • 20:07 Events are immutable facts that never change, meaning errors are corrected by appending new compensating events rather than modifying past data.
  • 21:15 CQRS separates read and write operations, allowing reads and writes to scale independently and utilize different data schemas or stores.
  • 27:42 Implementing event-sourced storage requires structuring events with a business identifier, a sequential version, metadata, and a payload blob.
  • 33:58 Optimistic locking and smart resolution strategies are essential for handling conflicting updates when multiple concurrent edits occur.
  • 36:05 Performance optimization in event sourcing often requires using snapshots to avoid loading the entire history of events on every read.

Takeaways

  • Preserve historical data instead of overwriting it to gain built-in auditing and easier debugging.
  • Decouple read and write models using CQRS to optimize performance and scalability for each use case.
  • Embrace eventual consistency and evaluate if full consistency is actually a strict business requirement.

Questions this talk answers

  • How does event sourcing differ from traditional CRUD architectures in terms of data storage?
  • When should a developer choose eventual consistency over full consistency?
  • How do you handle performance issues when an entity has accumulated thousands of events?

Technologies

PostgreSQL, MySQL, SQL Server, JavaScript, JSON

Tags

architecture, cqrs, database design, domain driven design, event sourcing, scalability