What is an event store and why do we want it?
An event store works like a full bank statement, where a traditional database is just the balance. The balance tells you where you stand today, while the statement shows every transaction that got you there. With an event store, that history is what you hand auditors and regulators when a decision needs explaining. And because nothing in an event store is ever overwritten, your teams can still answer questions years later that nobody thought to ask at launch.
The balance
One number, replaced every time something changes.
The full statement
Every transaction is added as a new line, and nothing is ever written over.
What does an event store give you?
Most systems remember only the latest version of every customer, order and account. When a customer disputes a charge, a regulator asks why an application was declined, or a product team wants to know why sign-ups dropped last spring, someone has to rebuild the answer from logs, backups and memory. With an event store the answer is already there, because every change was recorded as it happened.
Decisions you can explain. Every outcome traces back to the facts that produced it, in the order they happened, so an explanation takes minutes instead of an investigation.
Answers without a new project. New questions are answered from history you already keep, instead of waiting for engineering to build another report or data pipeline.
Mistakes stopped at the source. Rules such as never charging a customer twice or never selling the last seat to two people are checked the moment a change is made, not cleaned up afterwards.
What does that look like in practice?
A disputed payment
A customer says they were charged twice. Instead of reconciling records across several systems, the support team reads the account’s history and sees exactly which requests arrived, when, and why only one of them was accepted. The dispute is closed the same day, with evidence.
A claim under appeal
A claim was declined three years ago and the customer appeals. The team can show what the policy, the customer’s details and the rules looked like on the day of the decision, not just what they look like today.
A question nobody planned for
Marketing wants to know which promotions actually brought customers back. Because purchases were never overwritten, the analysis covers every year of history, not just the months since someone thought to start tracking it.
A course with one seat left
Two students try to enrol in a course with a single remaining place at the same moment. One enrolment is accepted, the other student is told the course is full and offered another. Nobody is overbooked, and nobody has to fix it by hand later.
Don’t we already have something like this?
Probably, in part. You most likely keep some history already, such as audit tables, application logs, a data warehouse or a stream of messages passed between systems. Each one records some of what happened, but none of them is the record your systems actually run on.
That difference shows up when it matters. Audit tables are added after the fact and miss whatever nobody thought to log. Logs are kept for weeks, not years. Warehouses hold copies that are often a day behind and can disagree with the live system. Message streams move information between systems, but they are not built to be the record of what happened.
Teams can build a full event store on top of a general-purpose database, and some do. It works, but it becomes a long-running project of its own that needs specialist engineers to build and look after, and that time comes out of the products customers pay for.
How does an event store help with audits, compliance and AI?
In regulated industries you are asked to show not only what you decided, but why, and on what information. An event store keeps that record by design, in order and unchanged, so the evidence for a decision is the same data your systems ran on rather than a separate audit log that can drift from it.
The same holds for automated decisions. When a rule engine or an AI agent approves, rejects or recommends something, the event store keeps the facts it acted on. That makes automated decisions explainable after the fact, which is increasingly what customers, auditors and regulators expect.
What does it cost, and what does it save?
Keeping every change sounds expensive. In practice the larger cost is usually what teams spend working around missing history, such as audit trails added after the fact, a new data pipeline for every new report, and incidents investigated without a record of what actually happened.
Older history can move to cheaper storage while staying available for audits and new questions. And because the history is kept in one place, there are fewer systems to buy, run, secure and staff.
RECENT YEARSFAST STORAGE
OLDER YEARSCHEAPER STORAGE
Why Axon Server?
Axon Server is Axoniq’s event store and message router in one system. Teams get the full history, the checks that keep it correct, and high availability built in, instead of assembling and maintaining those pieces around a general-purpose database.
That means less infrastructure to own and more engineering time spent on the products your customers pay for. With Axoniq Insights, analysts and product teams can also query that history directly, in plain language or SQL, without waiting for engineering to build a new report.
Axon Server
What is an event store?
An event store is a database that keeps every change in your application as an immutable, ordered event, retrieves one entity’s history efficiently even at billions of events, and validates every new event against that history before accepting it.
Any database can accumulate records, and none of them becomes an event store by doing so. The name is earned by the two operations that must hold under production load. Retrieval has to isolate one entity’s ordered history from billions of records during reads at latencies a live application can tolerate, and every append must be validated against the existing history at write time.
Each change goes after the last one. Recorded events never change.
One entity’s ordered history, isolated from billions of records.
Every append is validated against the existing history at write time.
What is an event?
An event is a record of something significant that happened in your system, written in past tense, e.g. RegistrationConfirmed or PaymentRejected. These are facts and are never changed afterwards: what happened, happened. When circumstances change, a new fact is appended after the old one rather than written over it.
That append-only shape, rather than a mutable table, is what separates an event from a database entry. A typical row in a relational database describes how things currently are, while an event describes what occurred, and a system built on events keeps every occurrence in order for as long as the history matters.
Named for the business fact, not the technical change. Handlers and queries select on it.
How is an event store different from a database?
A traditional database stores the answer, while an event store stores everything that produced said answer. Where a relational database holds an entity’s current status and nothing else, an event store holds every change that produced that status, in sequence, permanently.
One row, overwritten
Each change replaces the last value. The row says where the student is today, not how they got there.
| ID | STATUS | COURSES | CITY |
|---|---|---|---|
| s-1 | registered | 0 | Amsterdam |
An ordered history, appended
Each change is an immutable event, written after the last one and never written over.
Why store history instead of current state?
History answers questions that current state cannot. With only the current state, you know where the system is, but with full history you know how it got there, what it looked like at any past moment, and what you would find if you interpreted the same facts differently.
Keeping events in an audit log is enough for compliance, but the value compounds when a live application can retrieve and act on that history quickly enough to make timely, data-driven decisions while the request is still in flight.
The other payoff arrives later, when the business asks a question nobody anticipated at design time. Because the changes themselves were never thrown away, a new question is answered by reading the history rather than by wishing the data still existed.
What does an event store guarantee?
An event store guarantees consistency at the moment of append, immutability once an event is written, and strict ordering on read. The first is crucial because every new event is checked against the history already recorded, so conflicting facts are rejected before they enter the record rather than untangled after they corrupt it.
It helps to notice which of these is active and which is passive. Immutability and ordering describe how events sit at rest, but the consistency check runs on every single write, and it is what lets an event-sourced application enforce business rules structurally rather than hopefully, whether the rule is that no one registers twice or that no constrained resource is oversubscribed.
How does an application get current state back out of events?
Through an operation called sourcing, which reads one entity’s events in order and applies each one to a model until the model reflects everything that has happened to that entity. Out of a store holding billions of events, only those belonging to the entity in question are retrieved, which is exactly why efficient per-entity retrieval is a defining requirement of an event store.
Even sourcing a long history of a single model on every request would be too slow for production, which is where snapshots and caching come in. A snapshot periodically stores the computed state of an entity, so the application loads the most recent snapshot and applies only the events recorded after it. The performance section below walks through the mechanics.
What is the difference between event sourcing and a replay?
Event sourcing rebuilds the state of one entity for an operational decision, while a replay walks a much larger span of history to answer an analytical question. The two operations read the same events but serve different masters. Sourcing asks what is true about this one entity right now, and a replay asks what the entire history reveals when read end to end, ranking, counting, and aggregating across every entity the system has ever touched.
Replays are how an event-sourced system builds entirely new read models out of old data, which is the pattern CQRS describes, where the write side records events and the read side serves views built from them.
The index returns only student s-1’s events, folded into current state.
A cursor reads the whole log in order to build a view nobody planned for.
FOLDED FROM 0 EVENTS
Can you use Postgres as an event store database?
Postgres can act as an event store, but it is not designed around the access patterns and guarantees an event store needs. Every append requires the consistency check described above, and evaluating that condition efficiently against a table.
As the event store grows, the table itself becomes the constraint. There are ways to work around those limits, but they move into increasingly specialized engineering territory, turning your database into a specialist event-store project of its own. And requiring engineers with special skills and tying the project’s success to them, eating away resources from the business problem to be solved originally
That makes Postgres a workable starting point, but a less suitable foundation for a production event store than infrastructure designed specifically for the job. With Axon Server, event storage, consistency, replication, and the operational concerns around running an event store are built into the system rather than layered onto a general-purpose database.
Postgres can hold your events, but Axon Server is built to run your event store. The question isn’t whether Postgres can do it, it’s how much engineering you want to put around a database before it starts behaving like a system that was designed for this purpose.
A separate whitepaper puts numbers on that question, walking through what it actually costs to build an event store yourself once replication, ordering, recovery, and evolution become your responsibility.
Can you use MongoDB as an event store database?
MongoDB is an excellent document database, and storing events as documents works well at small scale. The gaps appear in the same places every DIY event store eventually encounters them.
Strict, gap-free ordering across concurrent writers is something you have to construct and defend yourself. Conditional appends become application logic wrapped in transactions rather than guarantees provided by the storage engine. And retrieving one entity’s complete, ordered history from billions of documents means designing and maintaining the indexing strategy yourself.
MongoDB can store events, but it’s a less suitable foundation for an event store than infrastructure designed specifically for event storage. MongoDB still has a role on the read side, where its document model and query flexibility shine.
Keep the event store as the source of truth, and let MongoDB serve the read models and projections built from it.
Can you use Kafka as an event store database?
No. Kafka is a message log built to move data through a system at high rates, and it does a great job at that. An event store is built to be the source of truth a system reasons about. The distinction is not about scale or durability, both of which Kafka has in abundance.
It comes down to the same two operations that define an event store anywhere else.
Kafka performs no validation of conditional appends. A producer writes to a partition and the broker accepts it, because the broker has no notion of the history that the writer is supposed to respect. Nothing checks whether a second registration contradicts the first, so the contradiction lands in the log and every consumer downstream inherits it.
The second gap is retrieval. Getting one entity’s complete, ordered history out of Kafka means replaying a partition from the beginning or maintaining a compacted topic keyed by entity, and neither gives you the indexed per-entity read that sourcing depends on. Compaction makes it worse, because compaction discards the intermediate records, and those are the history you were keeping in the first place.
Of course you can go that route, but congratulations, you now built an event store on top of Kafka, that you need to maintain for as long as your application lives.
Kafka earns its place beside an event store rather than instead of one. Keep the event store as the system of record, and let Kafka carry events outward to the systems that consume them.
Is it slow to event source millions of events?
It would be if systems actually did that on every request, and the reason they do not is a two-layer mechanism. Consider an entity whose history spans five thousand events.
With snapshots taken every hundred events, the first four thousand nine hundred are compressed into a single stored state by storing what the entity’s state was at that point. When a request arrives, the application loads that snapshot, applies only the few dozen events recorded since, and responds fast, without touching the thousands of events underneath.
Underneath is the operative word, because those events are compressed out of the hot path, not thrown away. If a bug corrupted the snapshots, the full history still exists to source from scratch and rebuild them correctly, and if a new analytical question arrives, the complete record is there to replay. Snapshots buy speed without spending history.
The second layer is aggregate caching, which removes the event store from the hot path on reads entirely for most cases. When the same instance of an application is always responsible for the same entity, that entity’s state is often still in memory from the last request, so the application applies its decision directly from cache and sends only the resulting append to the store. The consistency check in the event store makes this safe, because it verifies that the application’s view of history is current before accepting the event. Without that verification, a stale cache would write conflicting facts into the event store, and that would be the end of the system’s trustworthiness.
Apply every event since the entity was created.
With a policy of one snapshot per 100 events, events 1 to 4,900 are folded into one stored state.
Same entity, same instance, state still in memory from the last request. The store only verifies the append.
What does it cost to run an event store?
Less than many teams expect, and potentially less than they already spend working around tools not designed for long-term event retention. Keeping years of history in Kafka, for example, can mean over-provisioned broker storage or additional tiered-storage tooling. A purpose-built event store makes long-term retention a core capability.
Backups can also be more efficient. Because historical events are immutable, unchanged data does not need to be backed up from scratch every time. Incremental backups can focus on new data rather than recapturing the entire event history.
As data grows, multi-tier storage keeps frequently accessed events on faster, more expensive disks while moving older history to cheaper storage. Axon Server automates this process, keeping historical events available for replay and audits without requiring teams to build and maintain their own tiering logic.
How does an event store handle GDPR erasure requests?
GDPR’s right to erasure requires personal data to be erased when applicable. It does not prescribe a specific technical mechanism or require systems to preserve an unbroken event history. Preserving that history while meeting erasure obligations is an architectural choice.
Axon Server’s GDPR module uses cryptographic erasure, also known as crypto shredding. Personal fields are encrypted with keys associated with individual data subjects when events are written. When an erasure request is processed, destroying the relevant key makes those fields permanently unreadable while leaving the event history intact. Replay and auditability remain available for the data that can still be read.
The trade-off is key management. Because encrypted fields must be decrypted when accessed, the key management system becomes a dependency in the read path. That dependency needs to be designed for the availability and performance requirements of the application.
Crypto shredding only protects fields encrypted at write time. If personal data is inadvertently embedded in an event without encryption, destroying a key cannot erase it. In that case, event transformation can rewrite or remove the affected fields across relevant events. This approach requires identifying the affected data and managing the transformation carefully. Separating personal information from the record of what happened makes both approaches more practical, but neither is automatic or cost-free.
Both erasure methods must also be integrated into the system’s consistency and audit mechanisms. In Axon Server, the erasure request can be represented as an event, subject to the application’s consistency rules, so the system retains a record that the request was processed.
Benefits of an event store: an example
Everything highlighted in this page can be shown in an example of a single university system; follow one student through it.
Before any event reaches the store, the application decides what has to be true for that event to be valid, and attaches that requirement to the append as a condition. A request to register a student becomes an append carrying the “student registered” event alongside a condition: no registration already exists for this student. The event store evaluates that condition against the current history at the moment the append arrives, rather than trusting whatever the application assumed was true when it issued the request.
The story starts when the student registers. The application sends the append with its condition, the store checks the history, confirms no prior registration exists, and accepts the event into the record. Moments later a duplicate request arrives, perhaps from an impatient double click, carrying the same append with the same condition. This time the history already contains the registration, the condition fails, and the store rejects the event before a second registration can ever exist. No cleanup job, no deduplication logic downstream, and no idempotency key bolted on.
Years pass and the student’s history grows to five thousand events, registrations, course subscriptions, address changes, and everything between. When the student applies for a diploma, the application needs their complete current state to decide, and sourcing five thousand events for one decision would be slow. Because the store has been snapshotting every hundred events, the application instead loads the latest snapshot, applies the few dozen events recorded after it, and answers within a few milliseconds.
On the busiest days even that is more work than needed, since the application instance responsible for this student often still holds their state in memory from the previous request, appends the new event based on the model straight from cache, and relies on the store to verify the cache was up to date before accepting.
Let’s construct a conflict, our student and one other both try to subscribe to a course with a single remaining spot, at the same moment, through different application instances. Each append arrives promising it has read the latest events for both the student and the course, and both promises cannot hold, because whichever append lands first changes the course’s history. The store accepts one subscription, the course fills, and the second append is rejected, so that application instance re-reads the history, sees the course is full, and tells its student to choose another. The course never was overbooked, not even for a millisecond.
Long after all of this, the university asks which class has been the most visited in its history, a question the system was not designed to answer initially. No table holds that answer, but the events do. A replay walks every subscription and unsubscription ever recorded, counts registrations against departures per course, and ranks the result, a brand-new insight computed entirely from facts that were kept instead of overwritten. And when an audit reveals that email addresses were accidentally written into some of those events years ago, event transformation removes the personal fields from billions of records while every fact of what happened stays intact. Accurate answers and real business knowledge all thanks to the events stored over time.
A double click sends the registration twice.
Two appends through different application instances.
REQUEST 1APPEND
StudentRegistered s-1, condition: no registration for s-1
Axon Server: An Event Store Built for Reliability and Consistency
Axon Server is a purpose-built event store with consistency validation, efficient per-entity retrieval, snapshotting, multi-tier storage, and event transformation. These capabilities are built into the platform, reducing the need for teams to develop and maintain custom event infrastructure.
Axon Server supports large, long-lived event histories, with customers operating systems containing billions of events and many terabytes of data.
For engineering and product teams, that means
01
High availability by design. Clustered architecture replicates data across nodes to eliminate single points of failure.
02
Consistency across multiple entities. Dynamic consistency boundaries let teams enforce cross-entity guarantees without having to finalize aggregate boundaries before the first production event.
03
Adaptable event histories. Event transformation lets teams evolve how historical data is structured and interpreted without rewriting the underlying log.
04
Sustained query performance. Per-entity retrieval, snapshotting, and multi-tier storage help keep access efficient as event histories grow.
05
Less infrastructure to maintain. Teams can focus on product development instead of building and operating custom mechanisms for event storage, retrieval, and consistency.
For leadership, the result is a more durable foundation for enterprise systems. Teams can evolve business capabilities without repeatedly revisiting the infrastructure that supports them.
New events go to the end of the current segment. Closed segments are never changed in place.
segment 1CLOSED
segment 2CLOSED
segment 3CLOSED
segment 4OPEN
In aggregate-based contexts, a global index points to the latest event and per-segment pointers lead back, skipping segments in between. DCB contexts use a different index.
Computed state at a known position, kept in its own store. The application decides when to take one.
Closed segments move off primary disks by age or size.
PRIMARY · FAST DISK
OTHER TIER · ARCHIVE
axonserver-1LEADER
writes event 7
axonserver-2
waiting
axonserver-3
waiting
Why one system for both storing events and routing messages?
Because in a live event-sourced system, where a message is handled determines how fast the history can be used. Applications do not exchange only events, since a command such as “change my address” is the intent to do something, and the event is the proof that it happened. That intent has to reach the right place, because aggregate caching only works when requests for the same entity consistently land on the same application instance, where that entity’s state is already warm in memory. Route the command elsewhere and the cache is cold, the application sources from scratch, and the speed the architecture promised evaporates.
Splitting storage and routing across two systems means keeping two views of ownership and order aligned with each other, which is yet another distributed-systems problem acquired for no benefit. Combining them means the knowledge exists once, which is why Axon Server embodies both jobs in a single integrated system.
The broker does not know which instance holds the order’s state.
The routing key sends every command for o-7 to the same instance, as long as the set of instances is stable.
instance 1
instance 2
instance 3
Turning event history into business intelligence
Your event history contains far more information than your application needs to operate. It records the facts behind every decision and change, creating a valuable source of business intelligence. The problem is that accessing that history has traditionally required engineering work.
When a business team has a new question, engineers typically need to build a projection, replay the relevant events, and create a purpose-built database before anyone can get an answer. That makes every new question an engineering project.
Axoniq Insights, part of Axon Server, removes that dependency.
Let business and data teams query event history directly, in SQL or plain language, without asking engineering to build a new projection or pipeline.
Answer questions nobody anticipated when the system was built, in days instead of weeks.
Keep engineering focused on the application instead of servicing every new analytical request that comes in.
The data already exists. Insights makes it directly queryable, so engineering stops being the bottleneck between a question and an answer, and other departments get real business intelligence from history the system was already recording.
How do teams get started?
A short conversation with our team is usually enough to find the right first step for you.
Start where history matters most, such as disputes and refunds.
Add the next area. Its records join the same history.
Grow one area at a time, at your own pace.