Event-Driven Architecture
Architectural pattern where components communicate through asynchronous events, enabling decoupled, scalable, and reactive systems.
seed#event-driven#architecture#async#decoupling#events#messaging
What it is
Event-driven architecture is a pattern where components produce and consume events asynchronously. An event represents something that happened — an order created, a file uploaded, a user registered. Producers don't know who consumes their events; consumers don't know who produces them.
Components
- Event: immutable record of something that happened
- Producer: component that emits events
- Consumer: component that reacts to events
- Broker/Bus: infrastructure that routes events
Patterns
- Event notification: notify that something happened (without complete data)
- Event-carried state transfer: the event contains all necessary data
- Event sourcing: state is derived from the sequence of events
- CQRS: separate reads from writes using events
Broker comparison
| Broker | Model | Ordering | Retention | Use case |
|---|---|---|---|---|
| AWS SQS | Queue (point-to-point) | Optional FIFO | 14 days max | Simple service decoupling |
| AWS SNS | Pub/sub (fan-out) | Not guaranteed | No retention | Notifications to multiple subscribers |
| AWS EventBridge | Event bus | Per partition | 24h replay | Content-based routing, SaaS integration |
| Apache Kafka | Distributed log | Per partition | Configurable | High-volume streaming, event sourcing |
| RabbitMQ | Queue with exchanges | Per queue | Configurable | Complex routing, multiple protocols |
Benefits
- Decoupling: producers and consumers evolve independently
- Scalability: add consumers without modifying producers
- Resilience: isolated failures, automatic retries
- Auditability: complete event history
Challenges
- Eventual consistency (not immediate)
- More complex debugging (distributed flows)
- Event ordering
- Consumer idempotency
Why it matters
Event-driven architectures decouple services in time and space. A service publishes an event without knowing who consumes it, enabling independent scaling, modification, and replacement of components. It is the pattern that enables truly modular systems.
References
- What do you mean by Event-Driven? — Martin Fowler, 2017.
- AsyncAPI — AsyncAPI Initiative, 2024. Specification for asynchronous and event-driven APIs.
- EventBridge Documentation — AWS, 2024. Serverless event bus service.