NOTE

Event Sourcing

What event sourcing is, why it is needed, how it addresses some CRUD problems, its disadvantages, and design notes.

Software Architecture & EngineeringCreated Updated 1 min readhistorical

This is a historical learning note and may contain outdated or incomplete understanding.

1. What Is Event Sourcing?

A software architecture pattern based on events.

Persist the system’s CUD events.

2. Why Is Event Sourcing Needed?

Traditional CRUD has some problems:

  1. It directly operates on the database, whose performance is relatively low.
  2. To prevent concurrency problems, locks, transactions, and so on need to be introduced, causing performance loss.
  3. Because data storage usually stores only the final state of the data, additional auditing mechanisms are needed to track the history of data changes.

How does event sourcing solve these problems?

  1. Introduce a message queue for asynchronous processing.
  2. Events are immutable + generate and store events for CUD operations. They can be used to replay the system to any state.

3. Disadvantages of Event Sourcing

  • The storage consumed by events may be very large.
  • Only eventual consistency can be achieved.

4. How to Design Event Sourcing

5. References

Discussion

Sign in with GitHub to comment. Discussions are stored as GitHub Issues.View on GitHub