NOTE
Event Sourcing
Event sourcing persists data changes as events. These notes start with traditional CRUD limitations and examine recording state changes through events.
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.
The system’s CUD events are persisted.
2. Why Is Event Sourcing Needed?
Traditional CRUD has some problems:
- It directly operates on the database, whose performance is relatively low.
- To prevent concurrency problems, locks, transactions, and so on need to be introduced, causing performance loss.
- 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?
- Introduce a message queue for asynchronous processing.
- Events are immutable, and events generated for CUD operations are stored. Replaying these events can restore the system to any of its states.
3. Disadvantages of Event Sourcing
- Events may require a large amount of storage.
- Only eventual consistency can be achieved.
4. How to Design Event Sourcing
5. References
Drag to pan, scroll to zoom, and click a node to expand or collapse it. Large maps start with deeper levels collapsed; click nodes to expand them.
Discussion
Sign in with GitHub to comment. Discussions are stored as GitHub Issues.View on GitHub