In the previous article, we discussed the evolution of stream processing engines. Today, let’s talk about an interesting phenomenon: why do engineers often think of HTTP when faced with real-time processing requirements?
HTTP: The engineer’s Swiss army knife
The product manager may excitedly say: "We need a real-time order statistics system!"
An engineer’s first instinct would be: "Just POST new orders to the stats service, update the counts, respond with success, done."
Why this instinct? Because HTTP feels like a Swiss Army knife for engineers:
- Familiarity: Both frontend and backend engineers use it daily.
- Rich tooling: Postman, curl, Swagger—whatever you need, it’s there.
- Minimal learning curve: Way easier than learning Kafka.
-
Easy debugging: A single
curl
command is enough to test.
This naturally leads to a synchronous model.
A closer look at HTTP approach
1. Architecture
- Backend (Producer): POST new orders to the stats service.
- Stats service (Server): Receive request → update in-memory counters → respond success.
-
Dashboard (Consumer): Sends a GET request to
/stats
every few seconds to fetch the latest data.
Flowchart:
Shop System --sync HTTP--> Stats Service <--sync HTTP-- Dashboard
Looks perfect, right? Any engineer could implement this in 5 minutes with no new tech to learn.
But…
2. Problems emerge when traffic grows
The HTTP synchronous model works fine under low traffic, but when the system scales:
(1) Tight coupling
The shop system has to wait for the stats service to process the request before completing the order. If the stats service slows down, the entire order API slows down.
(2) Traffic spike challenge
During high traffic, say 100,000 orders in a short period, the stats service would need to handle 100,000 concurrent HTTP requests—an obvious bottleneck.
(3) Fault tolerance issues
Network glitches or service restarts can result in lost stats, requiring additional retry or compensation mechanisms.
3. Why switch to an asynchronous model?
The core problem with the synchronous model is that transmission and processing are locked to the same timeline.
If one side slows down, the other suffers—like two people running tied together with a chain.
A better approach is to introduce a middle layer (message queue/event streaming platform):
- Backend: Just push new orders into the event stream, no need to wait for stats processing.
- Stats service: Pull data from the event stream and process at its own pace.
Three major benefits of asynchronous architecture:
- Stress-resistant: During spikes, queue orders first and process them gradually.
- Decoupled: Shop system and stats service don’t block each other.
- Fault-tolerant: Event streams can persist data, so services can recover after crashes.
Conclusion
The HTTP synchronous model is a great starting point and works well for small-scale systems. But as traffic grows, synchronous processing introduces coupling and scaling challenges.
That’s when asynchronous, event-driven architectures come into play. By decoupling producers and consumers via a middle layer, the system becomes much more resilient.
In the next article, we’ll dive into the classic Lambda Architecture, exploring how it elegantly addresses these problems while ensuring both speed and accuracy.
Top comments (0)