| Scale | Request-driven | Event-driven |
|---|---|---|
| 100 users | Simple synchronous calls; low latency; easy debugging | Basic event queues; low message volume; simple event handlers |
| 10,000 users | Increased API calls; higher latency; need load balancers; some retries | Growing event queues; need message brokers; asynchronous processing helps throughput |
| 1,000,000 users | API servers saturate CPU; DB connection limits hit; latency spikes; retries increase | Message brokers become bottleneck; event ordering and duplication issues; need partitioning and scaling consumers |
| 100,000,000 users | Multiple API clusters; global load balancing; DB sharding; caching layers essential | Distributed event brokers; multi-region replication; complex event routing; eventual consistency challenges |
Event-driven vs request-driven in Microservices - Scaling Approaches Compared
Start learning this pattern below
Jump into concepts and practice - no test required
For request-driven systems, the first bottleneck is usually the synchronous API servers and database connections because each request waits for a response, causing CPU and DB connection saturation as users grow.
For event-driven systems, the bottleneck often appears at the message broker or event queue, which must handle high throughput and maintain message order and durability.
- Request-driven: Use horizontal scaling of API servers behind load balancers, implement caching layers to reduce DB load, use connection pooling, and shard databases to distribute load.
- Event-driven: Scale message brokers horizontally (partition topics/queues), use multiple consumer groups for parallel processing, implement idempotent event handlers, and use dead-letter queues for failures.
- Both approaches benefit from CDN for static content and edge caching to reduce backend load.
Assuming 1 million users generating 1 request or event per second:
- Request-driven: 1 million QPS is beyond a single DB instance (max ~10K QPS). Need ~100 DB replicas or sharding. API servers need ~200-500 instances (assuming 2000-5000 concurrent connections each).
- Event-driven: Message broker must handle 1 million messages/sec. Kafka cluster with multiple brokers can handle ~100K-200K messages/sec per broker, so need 5-10 brokers. Consumers scaled horizontally to process events timely.
- Network bandwidth: 1 million requests/events with 1KB payload = ~1GB/s (~8Gbps), requiring high network capacity and efficient compression.
Start by clarifying the system's workload and latency needs. Discuss how synchronous request-driven systems handle user interactions directly, while event-driven systems decouple components for better scalability. Identify bottlenecks at each scale and propose targeted solutions like load balancing, caching, sharding, or message broker scaling. Use real numbers to justify your approach.
Your database handles 1000 QPS. Traffic grows 10x to 10,000 QPS. What do you do first?
Answer: Introduce read replicas and caching to reduce direct DB load. If writes increase, consider sharding or partitioning the database. Also, optimize queries and use connection pooling to handle more connections efficiently.
Practice
Solution
Step 1: Understand event-driven communication
Event-driven systems use messages or events to notify other services asynchronously, without waiting for a reply.Step 2: Compare with request-driven communication
Request-driven systems make direct calls and wait for responses, which is synchronous communication.Final Answer:
Services communicate by sending messages without waiting for immediate responses. -> Option AQuick Check:
Event-driven = asynchronous messaging [OK]
- Confusing event-driven with synchronous calls
- Thinking event-driven requires shared databases
- Assuming event-driven always uses batch processing
Solution
Step 1: Identify request-driven behavior
Request-driven means a service calls another and waits for the response before moving on.Step 2: Eliminate other options
Options A and D describe asynchronous or event-driven behavior; Service A writes data to a shared database for Service B to read later. describes shared database, not direct calls.Final Answer:
Service A calls Service B and waits for a response before proceeding. -> Option DQuick Check:
Request-driven = synchronous call and wait [OK]
- Mixing event-driven with request-driven
- Thinking shared database equals request-driven
- Confusing batch processing with request-driven calls
Solution
Step 1: Analyze asynchronous event processing
Service A sends an event and does not wait; Service B processes independently.Step 2: Identify the advantage
This allows Service B to handle events at its own speed without blocking Service A, improving scalability and decoupling.Final Answer:
Service B can process events at its own pace without blocking Service A. -> Option AQuick Check:
Asynchronous event-driven = decoupled processing [OK]
- Assuming sender waits for receiver
- Confusing shared database with event broker
- Expecting immediate response in event-driven
Solution
Step 1: Identify problem with synchronous calls
High latency and failures occur because the caller waits and depends on the callee's immediate response.Step 2: Apply event-driven solution
Switching to asynchronous events decouples services, allowing retries and better fault tolerance without blocking.Final Answer:
Replace synchronous calls with asynchronous events and retries. -> Option BQuick Check:
Event-driven improves reliability by decoupling [OK]
- Just increasing timeout doesn't fix failures
- Shared database doesn't solve latency issues
- Batching synchronous calls still blocks
Solution
Step 1: Analyze requirements for fast feedback and flexibility
Fast user feedback needs synchronous validation; flexible processing benefits from asynchronous events.Step 2: Combine architectures appropriately
Request-driven calls provide immediate validation; event-driven updates allow inventory to process independently and scale.Final Answer:
Use request-driven calls for order validation and event-driven for inventory updates. -> Option CQuick Check:
Mix sync for speed + async for flexibility [OK]
- Using only event-driven delays user feedback
- Using only request-driven limits scalability
- Batch processing is too slow for online orders
