Event-driven architecture
Also called EDA, event-driven design.
A way of designing software where parts of the system publish events about what happened, and other parts react to them on their own.
Last updated
What it is.
An event is a fact, such as order placed or payment failed. The service that saw it publishes the event to a broker or message queue. Any number of other services subscribe: one sends an email, one updates stock, one feeds analytics. The publisher does not need to know who is listening.
This is the opposite of a chain of direct calls, where the order service calls email, then stock, then analytics, and fails if any of them is down.
Why it matters
Events decouple parts of a system, so new features can be added by subscribing to existing events, and a slow consumer does not slow the main flow. The cost is that the flow is harder to follow and debug, and consumers must cope with delays and duplicates.
In a product build
We define event names and payloads as a contract and version them, write events in the same transaction as the data change (often with an outbox table), make consumers idempotent and trace events end to end in observability tools.
Common mistakes.
- 01
Using events for things that need an immediate answer, like checking a password.
- 02
Publishing an event and then failing to save the data, or the other way round.
- 03
No catalogue of events, so nobody knows what listens to what.
Work it out with a tool.
Related terms.
- Message queueA buffer that holds messages, such as tasks or events, until a worker is ready to process them, so the sender does not have to wait.
- WebhookAn HTTP request one system sends to a URL you choose as soon as an event happens, so you do not have to keep asking.
- IdempotencyThe property of an operation that has the same effect whether it runs once or several times, so it is safe to retry.
- MicroservicesA way of building an application as many small services, each owning one job and its own data, deployed independently.
- ETL (extract, transform, load)A data pipeline that pulls data out of source systems, cleans and reshapes it, and loads it into a destination such as a data warehouse.