Skip to main content
Dilectus
Software Architecture · Event-driven architecture

Event-Driven Architecture Explained: Events, CQRS, and Trade-offs

Learn how event-driven systems work, where CQRS and event sourcing fit, and when the added complexity is worth it in real software systems.

AI-generated explainer by Dilectus · · 7 min read

Event-driven architecture is a way to build systems where components react to things that already happened, instead of calling each other in a tight chain. It is useful when many parts of the system need to respond to the same change, or when you want to decouple write paths from follow-up work like notifications, analytics, and integrations.

The core idea is simple: one service publishes an event, and other services subscribe to it. The hard part is not sending the event — it is handling retries, duplicates, ordering, failures, and the fact that different parts of the system may see the change at slightly different times.

What an event-driven system looks like

An event is a record of something that happened in the past, such as OrderPlaced, PaymentCaptured, or UserSignedUp. The publisher does not know who will consume it. Consumers decide what to do when they see the event.

+---------+       publish        +------------------+
| Order   | ---- OrderPlaced ---> |   Event broker   |
| service |                       |  (Kafka/SQS/etc) |
+---------+                       +------------------+
     |                                    |
     |                                    +--> Notification service
     |                                    +--> Inventory service
     |                                    +--> Analytics pipeline
     |
     +--> writes its own database

A common flow is:

  1. A user places an order.
  2. The order service validates the request and saves the order.
  3. It publishes OrderPlaced.
  4. Other services consume that event independently.
  5. Each consumer updates its own state or triggers side effects.

This is different from a synchronous chain where the order service would directly call inventory, payment, shipping, and email services one after another.

Why teams use events

Event-driven design is mainly about reducing coupling. If the order service only publishes events, it does not need to know which consumers exist today or tomorrow. That makes the system easier to extend without editing the original service for every new feature.

It also helps with load smoothing. A broker can buffer bursts of traffic, and consumers can process messages at their own pace. For example, if a flash sale creates 50,000 order events in a few minutes, the notification and analytics consumers can catch up asynchronously instead of slowing down checkout.

Typical benefits:

  • Loose coupling: producers and consumers evolve more independently.
  • Better scalability for side work: slow tasks move off the request path.
  • Resilience: if one consumer is down, others may still continue.
  • Natural audit trail: events can form a history of business changes.

But there is a cost: the system becomes harder to reason about because state is spread across services and time.

Events, commands, and queries are not the same

A lot of confusion comes from mixing up three different ideas.

ConceptMeaningExampleWho decides?
CommandA request to do somethingCreateOrderThe caller asks
EventA fact that something happenedOrderPlacedThe system reports
QueryA request for dataGetOrderStatusThe caller asks

A command can fail. An event, once published, should describe something that already happened in the system’s view. That distinction matters because consumers should not treat events as requests; they are observations.

A practical rule: use commands for intent, events for facts, and queries for reads.

Where CQRS fits

CQRS stands for Command Query Responsibility Segregation. In simple terms, it means using different models or paths for writes and reads.

In many systems, the write model is optimized for correctness and business rules, while the read model is optimized for fast lookups and user-friendly screens. Events are often used to keep read models updated.

Example flow

  1. CreateOrder command hits the write side.
  2. The order service validates inventory, pricing, and payment rules.
  3. It stores the order and emits OrderPlaced.
  4. A read model consumer updates a denormalized table like order_summary.
  5. The UI reads from order_summary for fast display.

This can be useful when the read shape is very different from the write shape. For example, an admin dashboard may need totals, counts, and recent activity, while the transactional model stores normalized tables and strict invariants.

CQRS does not automatically mean multiple databases, multiple services, or event sourcing. Those are separate choices.

Where event sourcing fits

Event sourcing goes one step further: instead of storing only the latest state, you store the sequence of events that led to that state. The current state is rebuilt by replaying events.

For example, an account balance may be derived from events like MoneyDeposited and MoneyWithdrawn. The event log becomes the source of truth.

This gives you a full history, which is powerful for auditability and debugging. But it also adds complexity:

  • You must version events carefully as business rules change.
  • Replaying a long history can become expensive without snapshots.
  • You need a clear strategy for rebuilding projections.
  • Debugging is harder if teams are not used to thinking in event histories.

Event sourcing is worth considering when the history itself is important, such as financial ledgers, compliance-heavy domains, or systems where you need to reconstruct past states accurately.

Delivery guarantees and the messy reality

Most production event systems do not guarantee perfect exactly-once processing end to end. In practice, you usually design for at-least-once delivery, which means a consumer may see the same event more than once.

That leads to a few important patterns:

  • Idempotent consumers: processing the same event twice should not break data.
  • Deduplication keys: store processed event IDs to ignore repeats.
  • Outbox pattern: write the business data and the event record in one local transaction, then publish later.
  • Retry with backoff: transient failures should be retried safely.
  • Dead-letter queues: poison messages should be isolated for later inspection.

A realistic example: if an email consumer receives OrderPlaced twice, it should not send two confirmation emails. The consumer can store event_id and skip duplicates.

Common failure modes

  • A service saves data but crashes before publishing the event.
  • A consumer updates its database but crashes before acknowledging the message.
  • Two events arrive out of order.
  • A schema change breaks old consumers.

These are normal problems in event-driven systems, so the design must assume them from day one.

When to use it (and when not to)

Use event-driven architecture when:

  • Multiple services need to react to the same business event.
  • You want to move slow side effects off the user request path.
  • You expect the system to grow new integrations over time.
  • You need a history of what happened, not just the latest state.
  • Bursty traffic makes asynchronous buffering valuable.

Avoid it, or keep it very limited, when:

  • The workflow is small and a direct synchronous call is easier.
  • The team is new to distributed systems and needs simpler debugging.
  • Strong consistency across several steps is required immediately.
  • The domain has few consumers and little chance of reuse.
  • The added operational burden of brokers, consumers, retries, and observability is not justified.

A useful heuristic: if the only reason to add events is “it sounds modern,” it is probably not worth it. If events remove real coupling or unblock independent scaling, they may be the right tool.

Operational concerns that matter in real systems

Event-driven systems need better observability than a simple request-response app.

You usually want:

  • Correlation IDs to trace one business action across services.
  • Structured logs with event IDs and consumer names.
  • Metrics for lag, retry counts, dead letters, and processing time.
  • Schema versioning so old consumers do not break instantly.
  • Access controls because events can leak sensitive data if you broadcast too much.

Security is easy to overlook. An event bus is not a free-for-all mailbox. Only publish the fields consumers truly need, and treat events as data that may be stored, replayed, and copied widely.

How this comes up in interviews

Interviewers usually probe whether you understand the trade-offs, not whether you can list buzzwords.

They may ask:

  • Why use events instead of synchronous service calls?
  • How do you avoid duplicate processing?
  • How do you keep a read model in sync?
  • When would you choose CQRS or event sourcing?
  • What happens if a consumer is down for an hour?

A strong answer usually sounds like this:

  1. Start with the business need: decoupling, scale, or auditability.
  2. Explain the flow from command to event to consumers.
  3. Call out delivery semantics and idempotency.
  4. Mention operational pieces like retries, dead-letter queues, and observability.
  5. Finish with when you would not choose it.

If asked to design a system, do not jump straight to Kafka or microservices. First identify which parts truly benefit from asynchronous events and which should stay synchronous for simplicity.

Key takeaways

  • Event-driven architecture lets services react to facts instead of calling each other directly.
  • It is useful for decoupling, buffering bursts, and moving side effects off the request path.
  • CQRS separates write and read paths; event sourcing stores the event history as the source of truth.
  • Most real systems must handle duplicates, retries, out-of-order delivery, and schema changes.
  • The main trade-off is simplicity versus flexibility and scale.
  • Use it when the problem is real, not just because asynchronous systems sound attractive.

Frequently asked questions

Is event-driven architecture the same as microservices?
No. Event-driven architecture is a communication style, while microservices is a way to structure services and teams. You can use events inside a monolith, across microservices, or in a hybrid system.
Do I need Kafka to build an event-driven system?
No. A queue, a stream platform, or even a database-backed outbox plus a worker can support event-driven flows. The right choice depends on throughput, ordering needs, retention, and operational complexity.
What is the biggest mistake teams make with events?
Treating events like a magic replacement for all synchronous calls. If you do not design for duplicates, ordering, schema evolution, and observability, the system becomes fragile very quickly.
When is event sourcing worth the extra complexity?
It is most useful when the history of changes matters as much as the current state, such as in audit-heavy or financial domains. For ordinary CRUD systems, storing the latest state plus a normal audit log is often simpler and enough.