Part of series: System Design Roadmap
Week 5 Day 4: Event-Driven Architecture - Reacting to Change
In a Monolith, Service A calls function B. In Event-Driven, Service A shouts “Something happened!” and B reacts.
Request-Driven (REST/gRPC)
- Order Svc calls Inventory Svc.
- Inventory Svc calls Shipping Svc.
- Tight Coupling: If Shipping is down, Order fails.
Event-Driven
- Order Svc emits
OrderPlaced. - Inventory Svc consumes
OrderPlaced, emitsInventoryReserved. - Shipping Svc consumes
InventoryReserved, emitsPackageSent. - Loose Coupling: Services don’t know each other exists.
Choreography vs Orchestration
- Choreography: Dancers knowing their own steps. (Services react to events independently).
- Hard to visualize the whole flow.
- Flexible.
- Orchestration: A Conductor (Orchestrator Service) tells everyone what to do.
- “Inventory, reserve items.” -> “Done”.
- “Shipping, ship items.” -> “Done”.
- Easier to debug.
Pros & Cons
- Pros: Scalable, Resilient, Easy to add new features.
- Cons: Complexity. Hard to debug “Why didn’t the shipping happen?” (Traceability).
Tomorrow: Mini Project. We build a robust Job Queue system! 👷