Event Storage - Event-Driven Architecture Performance optimization
Posted on the 3rd of April, 2025

In Event-Driven Architecture (EDA) having an Event Storage is usefull in certain situations. But before we discuss event storage optimizations, let's discuss event sourcing—because without understanding it, optimizing storage will make little sense.
Event Sourcing
Event Sourcing is a pattern where every state change in an application is stored as a sequence of event objects, each with a timestamp and action details. This means you don't just store the current state of something; you keep a full history of all changes.
To make it relatable, consider tracking an online order. Normally, you can check where your package is right now. But with event sourcing, you'd see every step of the journey—from the moment you click "Buy" to when it's delivered to your doorstep.

Why is Event Sourcing Useful?
There are a lot of advantages, but I believe they all resume to the fact that event sourcing helps with the following:
- Auditability – You get a detailed history of everything that happened.
- Rebuildability – You can reconstruct the past state, so never "worry" about losing data.
- Flexibility – Different services can react to real-time events or replay them when needed.
Of course, this approach isn’t free of trade-offs. Event sourcing adds complexity to an architecture, and managing storage efficiently becomes a top priority. But when performance and scalability are crucial, it’s worth it. I’ll leave you with a nice article on the topic [1].
[1] https://learn.microsoft.com/en-us/azure/architecture/patterns/event-sourcing
Is Event Sourcing the Same as Event-Driven Architecture (EDA)?
That is a question that people ask a lot. Well, believe me or not, the answer is nope! They both walk around the topic of events, but they serve different purposes:
- EDA is about services communicating in real-time when events happen.
- Event Sourcing is about storing data changes as a sequence of events.
They might not be the same, but they work beautifully together—you can use event sourcing to persist events and EDA to notify other systems about them. This results in a decoupled, auditable, and scalable system.
Event Storage: Where Do We Keep These Events?
Alright, now that we’ve set the foundation, let's get into event storage. The way you store events directly impacts performance. Typically, there are two main approaches:
In-Memory (Queue-Based) Storage – Fast but Ephemeral
This strategy relies on an in-memory queue, meaning each event is consumed by one service and then deleted. That’s also how reliability is achieved. Since the consumer has no state, it always receives the first event from the queue. If the consumer crashes before processing an event, no problem—the system ensures it picks up where it left off.

So, suppose another consumer arises and needs the same information that is being produced. In that case, the queue must be duplicated as a different queue (the new consumer won’t have access to previous events).
It's a good solution to achieve high efficiency on work queues (jobs that are completely independent and need to be executed within a certain amount of time).
Since it relies on memory for speed, it typically enforces a retention policy so the events expire after a timeout if not consumed to avoid unlimited growth.
If you’re familiar with RabbitMQ, this is how it works.
Log-Based
Instead of deleting events after they’re consumed, a log-based system (like Kafka or Redpanda) appends them to a log on disk. Multiple consumers can read from it at their own pace without affecting each other.

With this strategy, you are able to replay events or add new consumers that can start from the beginning of the log at any time.
Of course, there are some trade-offs. Since this method involves writing to disk, it adds latency. But modern log brokers are optimized, so sequential writes can be extremely fast.
The storage approach improves scalability (many consumers decoupled in time) at the cost of using more storage and requiring consumers to have storage management to track their read position (offset).
Modern log-based brokers are optimized for sequential disk writes, making them blazingly fast. To keep storage under control, it’s recommended to use data compaction and retention policies.
Optimizing Log-Based Storage
Log-based storage is great, but it can spiral out of control if you don’t manage it properly. That’s where data compaction and retention policies come in.
Data compaction
Imagine you’re receiving temperature updates from a sensor every second. Do you really need every single past reading? Probably not.

One of the approaches in data compaction is to remove older redundant events and keep only the latest update for each key. For example:
- Before Compaction:
sensor_1: 25°C → 26°C → 27°C → 28°C
- After Compaction:
sensor_1: 28°C
Compaction thus optimizes storage by removing redundant data, ensuring the log doesn’t grow indefinitely when events update the same key.
Retention Policies
Another approach is time-based retention—where logs expire after a set period (e.g., 7 days). This means:
- Older events are automatically deleted, freeing up disk space.
- You balance history with storage needs—shorter retention = faster recovery but less replayability.

Tuning retention is an optimization exercise: keeping just enough history for your use case. Engineering teams should choose retention durations that balance business needs for replay or debugging against the performance overhead of managing large logs.
In practice, a combination of strategies is used: critical event streams might enable log compaction to maintain the latest state indefinitely while also enforcing time-based retention for all other events to cap storage growth.
In Conclusion
Choosing the right event storage strategy is key to scalability, performance, and reliability in an event-driven system.
If you need real-time processing, go with in-memory (queue-based) storage-it’s blazing fast but ephemeral. If persistence, replayability, and scalability matter more, log-based storage is your best bet—just be smart about compaction and retention.
At the end of the day, your decision should be based on your system’s needs:
- Need low latency and one-time processing? → Queue-based (in-memory).
- Need historical event replays and multiple consumers? → Log-based.
With the right storage strategy, you can unlock the full potential of Event-Driven Architecture, ensuring high throughput, durability, and efficient resource usage.
We at Qala are building an Event Gateway called Q-Flow—a cutting-edge solution designed to meet the challenges of real-time scalability head-on. If you're interested in learning more, check out Q-Flow here or feel free to sign up for free . Let’s take your system to the next level together.