Event sourcing ensures that all changes to application state are stored as a sequence of events. We can not only query these events, we can also use the event log to reconstruct past states, and as foundation to ‘automatically’ adjust the state to cope with retroactive changes.
The fundamental idea of event sourcing is that of ensuring every change to the state of an application is captured in an event, and that these events are themselves stored in the sequence they where applied. With these events we can:
The simplest way to use event sourcing is to start from a blank application state and then applying the events to reach te desired state. This could however be a slow process, particularly if there are many events. A faster alternative is to hold the current application state within memory. Should the application crash it replays the stored events. To even further speedup the process one could take at regular intervals snapshots and only replay the events that occurred after the snapshot was taken. New snapshots can be made at any time in parallel without bringing down the running application.