0
0
Microservicessystem_design~3 mins

Event-driven vs request-driven in Microservices - When to Use Which

Choose your learning style9 modes available
The Big Idea

What if your system could work on many things at once without waiting for answers?

The Scenario

Imagine a busy restaurant where every customer must personally ask the chef for each dish, waiting for the chef to finish before ordering the next. This is like a request-driven system where every action waits for a direct response.

The Problem

This approach causes long waits and confusion when many customers order at once. The chef gets overwhelmed, mistakes happen, and the kitchen slows down. Similarly, request-driven systems struggle with delays and tight coupling between services.

The Solution

Event-driven design changes this by letting customers place orders on a board. The chef picks up orders as they come, cooks them independently, and notifies when ready. Services communicate by sending events, allowing work to happen asynchronously and independently.

Before vs After
Before
response = service.call(data)
process(response)
After
service.emit(event)
// continue without waiting
onEvent(eventResponse, handle)
What It Enables

This approach enables systems to handle many tasks smoothly at the same time, improving speed, flexibility, and fault tolerance.

Real Life Example

Online shopping platforms use event-driven systems to update inventory, notify shipping, and send customer alerts without waiting for each step to finish before starting the next.

Key Takeaways

Request-driven systems wait for direct replies, causing delays under load.

Event-driven systems use asynchronous messages to work independently and faster.

Choosing event-driven design helps build scalable, resilient microservices.