Imagine your API has a popular endpoint:
GET /products/123
Suddenly, 100 users request the same product at nearly the same time.
Your cache has just expired.
Instead of one database query, your backend may now execute the same query 100 times.
The users asked for one piece of data. Your database did the work 100 times.
This is the problem request coalescing is designed to solve.
What Is Request Coalescing?
Request coalescing, also called the single-flight pattern, combines concurrent requests for the same resource into one in-flight operation.
The first request performs the expensive work.
The other requests wait for that operation and receive the same result.
100 identical requests
↓
Request Coalescing
↓
1 backend request
↓
100 responses
The important part is that coalescing is about work that is currently in progress. It is not a replacement for caching.
The Problem With a Normal Cache
Consider a typical cache-aside flow:
Request
↓
Check cache
↓
Cache miss
↓
Query database
↓
Store result
Now imagine 100 requests arrive before the first database query finishes.
All of them can see the same cache miss:
Request 1 → Cache miss → Database
Request 2 → Cache miss → Database
Request 3 → Cache miss → Database
...
Request 100 → Cache miss → Database
This is often associated with a cache stampede or thundering-herd effect.
The cache normally protects the database. During a synchronized miss, it can temporarily disappear as that protection.
How Coalescing Changes It
With request coalescing, the first request becomes the leader.
Request 1 → starts database query
Request 2 → waits
Request 3 → waits
Request 4 → waits
...
Request 100 → waits
Database → executes once
↓
result is shared
↓
waiting requests
So instead of 100 expensive operations, there is only one in-flight operation for that key.
A Simple Example
A simplified Node.js implementation can keep track of requests currently in progress:
const pending = new Map();
async function getProduct(id) {
if (pending.has(id)) {
return pending.get(id);
}
const promise = database.query(
"SELECT * FROM products WHERE id = $1",
[id]
);
pending.set(id, promise);
try {
return await promise;
} finally {
pending.delete(id);
}
}
The important idea is the pending map.
If another request for the same product arrives while the first query is still running, it gets the same Promise instead of starting another database query.
Why This Is Not Just Caching
Caching answers:
Do we already have the result?
Request coalescing answers:
Is somebody already fetching this result?
They work well together:
Request
↓
Cache hit? ── Yes → Return cached value
│
No
↓
Already fetching? ── Yes → Wait for existing request
│
No
↓
Fetch from backend
↓
Update cache
↓
Return result
This is why coalescing is especially useful around expensive cache misses.
What Happens in Multiple Servers?
There is an important limitation.
An in-memory Map only coordinates requests inside one application process.
If your application has five servers:
Server A → 1 database query
Server B → 1 database query
Server C → 1 database query
Server D → 1 database query
Server E → 1 database query
each server can still perform its own request.
For coordination across multiple instances, you need a distributed mechanism, often involving shared infrastructure such as Redis or another distributed coordination system.
This is one reason solutions such as Go's singleflight are useful within a process, but do not by themselves solve coordination across an entire fleet. (pkg.go.dev)
Where Is Request Coalescing Useful?
It works best when many clients can ask for the same expensive thing at the same time.
Common examples include:
- Popular database records
- Expired cache entries
- Expensive API calls
- Configuration loading
- User or product lookups
- Expensive computations
It is particularly valuable when the backend operation is slow enough for many duplicate requests to overlap.
The Bigger Idea
Caching reduces repeated work over time.
Request coalescing reduces repeated work at the same time.
That difference is small but important.
A good caching system might prevent thousands of requests from reaching your database. But when a popular cache entry expires, request coalescing can make sure those concurrent misses do not immediately turn into thousands of identical backend operations.
The goal is simple:
100 callers
↓
1 expensive operation
↓
100 callers get the result
The smartest backend is not always the one that processes requests faster. Sometimes it is the one that realizes that 100 requests are asking for exactly the same work.



