If the order service calls stock, invoicing and shipping one after another at confirmation, the slowest link in that chain slows every order, and adding a new system means changing the order service's code. Event-driven architecture reverses the dependency: the order service only publishes an "order confirmed" event, and every interested service consumes it at its own pace.
This guide covers how request-response differs, the event types, schema rules, ordering and consistency problems, the outbox pattern, replay from an event log, monitoring, risks and the payback calculation. All figures are illustrative.
What Is Event-Driven Architecture?
Event-driven architecture is a design approach in which parts of a system publish events about what happened instead of calling each other directly, and interested parts react to those events. An event is a fact that already happened and does not change: "Order confirmed", "Invoice issued".
There are three roles: the publisher that produces the event, the broker that carries it (a queue or stream layer) and the subscribers that process it. The publisher does not know who is listening. We covered queue mechanics in our message queue guide and notifying outside systems in our webhook guide; this article focuses on the architectural decisions built on top of them.
We recommend reading: What is a message queue and asynchronous processing?
How Does Event-Driven Differ from Request-Response?
In request-response the caller waits for an answer and knows the other service; in event-driven the publisher waits for nothing and does not know the subscriber. Both are valid and suit different problems.
| Topic | Request-response | Event-driven |
|---|---|---|
| Dependency | Caller knows the callee and its address | Publisher knows only the event contract |
| Failure spread | If the callee is down, the caller suffers | If a subscriber is down, events wait; the publisher keeps working |
| Consistency | Immediate; work is done when the response returns | Eventual; subscribers finish seconds later |
| Response time | Sum of the calls in the chain | Only the publisher's own work plus publish time |
| Traceability | Linear call chain, easy to follow | Scattered flow; a correlation ID is essential |
| Adding a receiver | The publisher's code changes | A subscriber is added; the publisher is unchanged |
Two illustrative numbers make the difference concrete. If order confirmation calls stock (40 ms), invoicing (60 ms) and shipping (80 ms) in sequence, the response is 20 + 40 + 60 + 80 = 200 ms including the publisher's own 20 ms. Event-driven, the publisher waits only for its own work and the publish step (10 ms): 30 ms. Availability differs too: if every service is 99.5% available, a four-link chain gives 0.995⁴ ≈ 98.0%, which is about 858 minutes of downtime in a 30-day month (43,200 min). If only the publisher and a 99.9% broker must be up, order intake is 0.995 × 0.999 ≈ 99.4%, about 259 minutes. The math assumes independence, and subscribers' work is delayed, not removed.
What Are the Event Types and How Do You Name an Event?
Three types are often confused: event notification, event-carried state transfer and command.
| Type | Content | Upside | Downside |
|---|---|---|---|
| Event notification | Only the ID and what happened | Small, carries no personal data | Subscriber calls back for details |
| Event-carried state transfer | All fields the subscriber needs | No callback; subscriber works independently | Large payload, data spread, staleness risk |
| Command | A "do this" instruction; one receiver | Clear responsibility | Publisher stays dependent on the receiver |
The difference shows in numbers. At a peak of 500 orders/sec with 3 subscribers, a notification-only design sends the order service 500 × 3 = 1,500 callbacks per second. State-carrying events remove that load, at the price of bigger payloads and personal data travelling with the event. For personal data placed in events, consult your legal counsel about KVKK (Turkey's personal data protection law).
Naming reflects the event–command difference. An event is written in the past tense and reports a fact: OrderConfirmed. A command is imperative: IssueInvoice. A name like "ConfirmOrder" looks like an event but is a command; the publisher has made the subscriber's decision and the decoupling breaks.
How Do You Design and Version an Event Schema?
The event schema is the contract between publisher and subscribers. Every event should also carry a unique event ID, a timestamp, a schema version and a correlation ID.
- Backward-compatible change: Adding a new optional field. Old subscribers ignore fields they do not know.
- Breaking change: Removing a field, renaming it, changing its meaning or type. A new version is published and the old one runs in parallel for a while.
- Tolerant reading: Subscribers do not turn unknown fields into errors; the principle is the same in API integration.
An example rule: for a breaking change, publish a new version, keep the old one for 90 days in parallel and do not shut it down until every subscriber has moved. The cost is producing two versions at once, so design the schema through discussion up front.
How Does Decoupling Make Adding Subscribers Easier?
With direct calls, a new receiver means a new dependency and a deployment for the publisher; with events, only the new subscriber is written.
If order service A is directly tied to invoicing, stock and shipping (B, C, D), it has three dependencies. A fourth receiver (E, reporting) needs a new call, test and deployment in A. With events, A has exactly 1 dependency, the broker, and E subscribes on its own. If six services all talk to each other, that is 6 × 5 ÷ 2 = 15 possible connections; through a broker each service has one connection, so 6. For service boundaries, see our microservices guide.
How Is Event Order Preserved, and What Is a Partition Key?
Ordering is usually guaranteed only within one partition. Using the order ID as the partition key puts all of an order's events in one partition, in order.
An example: an order has three events: created, confirmed, cancelled. Spread over 6 partitions without a key, the chance that all three land in the same partition is (1 ÷ 6)² = 1 ÷ 36 ≈ 2.8%, so order can often break and the cancellation may be processed before the confirmation. With the order ID as key, all three share a partition and order holds. The cost is a parallelism ceiling: at most 6 subscriber instances run. At a peak of 500 events/sec and 100 events/sec per instance, 500 ÷ 100 = 5 instances are needed, so 6 partitions are enough.
What Is Eventual Consistency and How Do You Set a Latency Budget?
Eventual consistency means the whole system reaches the same result not at the same instant but after a short delay. The business decides the acceptable delay; turn it into a written budget.
Example target: after an event, the read model (the order list screen) updates within p95 ≤ 2 sec. Split it by stage: publish 0.2 sec, waiting in the broker 0.4 sec, subscriber processing 0.9 sec, write 0.5 sec; total 0.2 + 0.4 + 0.9 + 0.5 = 2.0 sec. Adding p95 values is a conservative estimate.
The screen is designed accordingly: a new order shows locally as "processing". Because the same event can arrive more than once, subscribers must be idempotent: store processed event IDs in a table and skip the second arrival. With 60,000 events a day and 7 days of retention, the table holds about 420,000 rows.
What Is the Dual Write Problem and the Outbox Pattern?
The dual write problem occurs when one operation must both write to the database and publish an event, and only one of the two can succeed. The record is saved, the event is not sent, and the system silently becomes inconsistent.
Illustrative probabilities: database write failure p1 = 0.1%, publish failure p2 = 0.2%. If you write first and publish second, "record exists, no event" has probability (1 − p1) × p2 = 0.999 × 0.002 ≈ 0.2%. At 20,000 orders a day that is 39.96, about 40 lost events, roughly 1,200 inconsistent orders in 30 days. Reversing the order does not help: "event exists, no record" produces about 0.001 × 0.998 × 20,000 ≈ 20 phantom events a day.
The fix is the outbox pattern: the order record and an "event to publish" record are written in the same database transaction, so both succeed or both roll back. A separate relay forwards the outbox records to the broker and marks them. The event goes out at least once, so the subscriber must be idempotent. If the relay scans every second, it adds at most 1 sec to latency.
What Are an Event Log and Replay Good For?
An event log keeps events durably and in order. While they are kept, past events can be replayed to build a new view (a report table, a search index) from scratch.
Illustrative example: you want a monthly order summary per dealer. With 1,000,000 events in the log and a subscriber processing 20,000 events/sec, it takes 1,000,000 ÷ 20,000 = 50 sec. While live traffic continues, 500 × 50 = 25,000 events pile up; at a net speed of 19,500 events/sec they clear in 25,000 ÷ 19,500 ≈ 1.3 sec, so the total is about 51.3 sec. For the analytics-store side, see our data warehouse guide.
Event sourcing goes one step further: it stores the events that build the state, not the state itself. In a dealer balance example, an opening ₺10,000, an order of −₺4,200 and a refund of +₺600 give a balance of 10,000 − 4,200 + 600 = ₺6,400. A snapshot is taken every 100 events. It is valuable when an audit trail is required; for a simple application it is needless complexity.
How Do You Monitor an Event Flow?
In a scattered flow, "where did the event get stuck?" is answered by three things: consumer lag, the dead-letter queue and the correlation ID. General principles are in our monitoring guide.
- Consumer lag: The gap between the last event produced and the last one the subscriber processed. If production is 500 events/sec and consumption 400 events/sec, lag grows by 100 events each second. With an alarm threshold of 2 seconds' worth of flow, that is 1,000 events, reached in 1,000 ÷ 100 = 10 sec. Measure how many seconds of work are behind rather than the event count.
- Dead-letter queue: Events that could not be processed despite repeated attempts. At 60,000 events a day, a 0.1% threshold is 60 events; if exceeded, a person looks.
- Correlation ID: A shared ID across all events and logs of one order as it passes through five services.
For the process after an alarm, see our incident management guide.
What Are the Event Storm and Contract Ownership Risks?
An event storm is when events trigger other events and the chain gets out of control. Nobody is left who sees the whole flow.
If each event produces 3 reactions and the chain reaches depth 4, a single trigger creates 1 + 3 + 9 + 27 + 81 = 121 events. If the chain loops back (A, B, C, A again), it becomes an infinite loop. The remedy: keep a hop counter in the event header with an upper limit (for example 5) and draw the chains to look for cycles. Ownership: the schema belongs to the publishing team; changes are announced in advance and subscriber expectations are checked with contract tests.
When Is Event-Driven Architecture Not Suitable?
It is not suited to simple record keeping or work that needs instant, strict consistency. The table shortens the choice.
| Situation | Recommendation | Reason |
|---|---|---|
| One team, one database, simple CRUD | Request-response | Broker and monitoring overhead exceed the gain |
| Credit limit or stock reservation needing instant strict checks | Synchronous call or lock | Eventual consistency is not enough; see our concurrency guide |
| Three or more independent reactions to one event | Event-driven | Receivers are added without changing the publisher |
| A nightly batch is enough | Scheduled job | No instant reaction needed; see our batch processing guide |
A hybrid design is often best: the instant, strict step stays synchronous, and what follows flows through events.
How Do You Move to Event-Driven Architecture?
Start with one flow.
- Pick a flow: Choose one with a publisher and at least two independent reactions, for example invoicing and notification after "order confirmed".
- Contract: Name it in the past tense; set the schema, version, ID and correlation fields; assign an owner.
- Outbox: Tie publishing to the database transaction and set up the relay.
- Subscribers: Write them idempotent; define the dead-letter queue and retry rule.
- Monitoring: Put lag, dead letters and the correlation trace on a dashboard; write the alarm thresholds.
- Expansion: Once the first flow is healthy, add a subscriber and move on to the second flow.
How Do You Calculate the Payback of Event-Driven Architecture?
Illustrative assumptions: adding a new integration takes 4 working days instead of 15; 6 new integrations are added a year; a person-day costs ₺9,000; initial setup takes 45 person-days; annual operations (broker, monitoring, on-call) cost ₺60,000.
- Saving per integration: 15 − 4 = 11 days; per year 11 × 6 = 66 days × ₺9,000 = ₺594,000.
- Annual net gain: ₺594,000 − ₺60,000 = ₺534,000.
- Investment: 45 × ₺9,000 = ₺405,000.
- Payback: ₺405,000 ÷ ₺534,000 ≈ 0.76 years, about 9.1 months.
Sensitivity matters: if only 2 new integrations are added a year, the saving is 22 × ₺9,000 = ₺198,000, net ₺138,000, and payback is ₺405,000 ÷ ₺138,000 ≈ 2.9 years, about 35.2 months. The value depends on integration frequency; in a rarely changing system a simpler approach may be cheaper.
We recommend reading: How to Set Up Centralized Log Management: Structured Logs, Retention and Cost Guide
We recommend reading: How to Design an Offline-First App: Local Data, Sync, Conflict Resolution and Payback Guide
We recommend reading: What Is Process Mining? Event Logs, Variants, Conformance Checking and Payback Guide
We recommend reading: What Is Serverless Architecture? Cold Starts, Limits, Break-Even Cost and When It Fits
We recommend reading: WebSockets vs SSE vs Polling: How to Choose Real-Time Updates for a Business App
We recommend reading: What Is the Saga Pattern and Distributed Transactions? Compensation, Step Order and Failure Math Guide
Custom Software and Integration with İnovabil
At İnovabil our focus is building custom software from scratch for your company: custom software, ERP, CRM, e-commerce, web, mobile and integration. Event-driven architecture is not the right choice for every project; in requirements analysis we suggest writing down the number of integrations, the change frequency and the consistency expectation, and first checking together whether a simpler design is enough.
We built logistics and shipment planning with wholesale order management for Karyak; warehouse management and a complaint and support management system for Sleepy; CRM, purchasing and mobile for Avcılar İnşaat; and a purchasing system for İZBAN. Send us a short summary of your system and we will prepare a written assessment.
We recommend reading: Our integration service
Frequently Asked Questions
What is event-driven architecture, in short?
A design in which services publish and consume events instead of calling each other directly. It separates the publisher from the receivers, so adding a receiver does not require touching the publisher.
Is a message queue the same as event-driven architecture?
No. A queue is the infrastructure that carries events; event-driven architecture is the approach to decoupling services through events. Not every system with a queue is event-driven.
Why is an outbox needed?
To guarantee the database write and the event publish in one transaction. Otherwise, in the example, about 40 events a day vanish silently. The record and the event are written together and a separate relay forwards the event to the broker.
How is event order guaranteed?
Order is usually kept only within one partition. Events whose order matters must be sent with the same partition key, for example the order ID; there is no ordering guarantee across different keys.
Is event-driven architecture right for every project?
No. For single-team systems with simple record keeping or instant strict consistency, request-response is simpler. When one event has several independent reactions and integrations change often, the event-driven approach pays off.