🚀

Module 2: The Problem Statement

25 minutes2 examplesBeginner

Hands-on Examples

Interactive examples to reinforce your learning

Traditional vs Event-Driven Architecture

Comparing traditional synchronous systems with event-driven architecture

Code Example
# Traditional Synchronous System (Problems)

## Order Processing Flow:
1. User places order
2. Order Service calls Inventory Service (SYNC)
3. Wait for inventory check
4. Order Service calls Payment Service (SYNC)
5. Wait for payment processing
6. Order Service calls Email Service (SYNC)
7. Wait for email confirmation
8. Return response to user

## Problems:
- High latency (sum of all service calls)
- Single point of failure
- Tight coupling
- Difficult to scale
- Complex error handling

# Event-Driven System (Solution)

## Order Processing Flow:
1. User places order
2. Order Service publishes "OrderCreated" event
3. Multiple services consume the event:
   - Inventory Service: Reserve items
   - Payment Service: Process payment
   - Analytics Service: Track metrics
   - Email Service: Send confirmation
4. Each service publishes its own events
5. Order Service updates status based on events

## Benefits:
- Low latency (asynchronous)
- Fault tolerant
- Loose coupling
- Easy to scale
- Simple error handling

Expected Output:

Event-driven architecture reduces latency from 5+ seconds to milliseconds while improving reliability and scalability.

Explanation:

This comparison shows how event-driven architecture solves the fundamental problems of traditional synchronous systems.