Why events?
In a request-driven design, the order service calls inventory, then payments, then notifications, then analytics. Each new consumer means changing the order service, and if any of them is down, ordering may fail.
In an event-driven design, the order service publishes OrderPlaced once. Inventory, payments, notifications and analytics each subscribe and react. Adding a new consumer (a loyalty-points service) needs no change to the producer.
Gains: loose coupling, independent scaling, natural buffering of spikes, an audit trail of what happened, and easy addition of new consumers.
Costs: eventual consistency, harder debugging (no single call stack), duplicate and out-of-order delivery to handle, and the risk of an invisible web of dependencies.
Commands vs events
| Command | Event | |
|---|---|---|
| Tense | Imperative: "ChargeCard" | Past: "PaymentCaptured" |
| Receivers | One handler expected | Zero to many subscribers |
| Coupling | Sender knows the receiver | Sender doesn't know who listens |
| Can be rejected? | Yes | No: it already happened |
Event design styles:
- Notification ("Order 881 changed"): tiny; consumers call back for details. Low coupling on schema, but consumers depend on the producer being up.
- Event-carried state transfer ("Order 881 changed; here is the full order"): consumers keep local copies and don't need to call back. More data, much more resilience.
- Delta events ("status changed from PAID to SHIPPED"): compact, but consumers must have seen every previous event to make sense of it.
Choreography vs orchestration
When a business process spans several services (place order → reserve stock → charge → ship), someone has to coordinate it.
| Choreography | Orchestration | |
|---|---|---|
| How | Each service reacts to events and emits its own | A central orchestrator tells each service what to do next |
| Coupling | Low; no central brain | Services coupled to the orchestrator's commands |
| Visibility | Hard: the flow is implicit in subscriptions | Easy: the flow is explicit in one place |
| Changing the flow | Touch several services | Change the orchestrator |
| Best for | Simple flows, broadcast reactions (analytics, notifications) | Multi-step business processes with compensation (Background Jobs, Schedulers and Workflow Engines) |
A practical mix: orchestrate the core business process (checkout, onboarding) so its state is visible and compensations are explicit, and choreograph the side effects (emails, analytics, search indexing) that simply react to its events.