Code on a screen, representing event sourcing.

Storing changes as a sequence of events, not just the final state.

What event sourcing is

Event sourcing is a way of storing data in which an application records the full sequence of changes as a series of events, rather than keeping only the current state. Each change is captured as an event and added to a log. The current state can then be derived by replaying these events from the beginning. This approach keeps a complete history of how the data reached its present form.

State versus events

In a traditional approach, a system usually stores just the latest state of its data, overwriting old values as things change. Event sourcing takes a different view: instead of storing only the current state, it stores every change as an event. The present state becomes a result of applying all those events in order. This shift from storing state to storing a history of changes is the essence of event sourcing.

Rebuilding state from events

Because event sourcing keeps the full sequence of events, the current state can be reconstructed by replaying them from the start. Each event is applied in turn, building up to the latest state. This means the state is not the only source of truth; the event log is. If needed, the system can also reconstruct what the state was at any earlier point by replaying events only up to that moment.

Benefits of event sourcing

Storing changes as events provides a complete, ordered history of everything that has happened, which can be valuable for auditing, understanding how data evolved, and analyzing past behavior. It also makes it possible to recreate previous states and to derive new views of the data from the same events. This rich history is a major reason some systems choose event sourcing.

Trade-offs to consider

Event sourcing is powerful but adds complexity compared to simply storing the current state. The system must manage a growing log of events and reconstruct state by replaying them, which requires careful design. It is best suited to situations where the full history of changes is genuinely valuable. Understanding both its benefits and its added complexity helps decide when event sourcing is the right choice.

Why it matters

Event sourcing offers a different way to think about data, treating the history of changes as the source of truth. Understanding what event sourcing is - storing changes as a sequence of events and deriving state by replaying them - clarifies a pattern used for auditing, flexibility, and insight into how data evolves. For anyone studying software architecture, it is a valuable concept.

See also: What is publish-subscribe? Explained, What is a relational database? Explained.

Sources

Published date reflects the original event date (2023-08-29). This article is original Skillo editorial written from the sources above; facts were verified in September 2026.

Skillo Staff

Skillo Staff

All stories by: Skillo Staff

Leave a Reply