SystemExpertsSystemExperts
Pricing

Patterns

35 items

Horizontal Scaling Pattern

15mbeginner

Retry with Backoff Pattern

15mbeginner

Replication Pattern

25mintermediate

Caching Strategies Pattern

25mintermediate

Persistent Connections Pattern

20mintermediate

Load Balancing Pattern

20mintermediate

Fan-out Pattern

20mintermediate

Fan-in Pattern

20mintermediate

Circuit Breaker Pattern

20mintermediate

Eventual Consistency Pattern

25mintermediate

Queue-based Load Leveling Pattern

20mintermediate

Bloom Filters Pattern

20mintermediate

Time-Series Storage Pattern

20mintermediate

Bulkhead Pattern

20mintermediate

Batch Processing Pattern

20mintermediate

Write-Ahead Log Pattern

20mintermediate

API Gateway Pattern

20mintermediate

Backend for Frontend Pattern

20mintermediate

Sidecar Pattern

20mintermediate

Idempotency Pattern

20mintermediate

Rate Limiting Pattern

20mintermediate

Backpressure Pattern

20mintermediate

Pub/Sub Pattern

25mintermediate

Strong Consistency Pattern

30madvanced

Conflict Resolution Pattern

25madvanced

Leader Election Pattern

25madvanced

Consensus Protocols Pattern

30madvanced

CQRS Pattern

28madvanced

LSM Trees Pattern

25madvanced

Sharding Pattern

25madvanced

Event Sourcing Pattern

30madvanced

Stream Processing Pattern

25madvanced

Change Data Capture Pattern

25madvanced

Distributed Locking Pattern

25madvanced

Two-Phase Commit Pattern

25madvanced
System Design Pattern
Communicationevent-sourcingevent-storeaudit-logreplayimmutableadvanced

Event Sourcing Pattern

Storing state as a sequence of events

Used in: Banking Systems, Order Management, Audit Systems|30 min read

Summary

Event Sourcing stores application state as a sequence of immutable events rather than as current state in a database. Instead of updating records in place, every state change is appended as an event to an event store. The current state is derived by replaying events from the beginning. This provides a complete audit trail, enables time travel, and supports event-driven architectures naturally.

Key Takeaways

Events as Source of Truth

In event sourcing, the database stores every event that ever happened. Current state is derived by replaying these events. This means you have a complete history of how the system reached its current state.

Immutability and Append-Only Storage

Events are immutable facts about the past—once written, they never change. The event store is append-only. Instead of fixing data by updating records, you append compensating events.

Time Travel and Replay

Since all historical events are preserved, you can reconstruct any past state by replaying events up to a point in time. This enables debugging production issues by replaying past events.

Event Schema Evolution

Unlike database migrations, you cannot change past events. This requires careful versioning: include a version field in every event, write code that handles multiple versions.

Snapshots for Performance

Replaying thousands of events to reconstruct state is too slow. Snapshots periodically capture state, allowing replay to start from the snapshot rather than the beginning.

Separation from CQRS

Event sourcing and CQRS are often used together but are distinct patterns. Event sourcing is about how you store data. CQRS is about separating read and write models.

Pattern Details

Traditional CRUD systems store only current state. When you update a record, the previous value is lost forever. This makes it impossible to answer questions about past states or maintain audit trails.

Trade-offs

AspectAdvantageDisadvantage