We use analytics cookies.We use cookies to analyze site traffic and improve your experience.
Loading...
This idea carries a full system design question on its own. Each walks through the full answer.
System Design Masterclass · Messaging Event Systems
Free preview: the first 2 parts of this 8-part lesson.
Already bought the course? Sign in to read the whole lesson.
this lesson is part of
System Design Masterclass
Unlock this lesson and the 751 other paid lessons
$25 once, by PayPal
See the System Design courseread the rest of this lesson in
System Design Masterclass
Unlock this lesson and the 751 other paid lessons
$25 once, by PayPal
See the System Design coursein Messaging Event Systems
This lesson is part of the full System Design Masterclass. Unlock it along with 769 other lessons for a one-time payment.
One-time payment by card or PayPal
Get Lifetime AccessOne-time payment: UPI, card or netbanking
Get Lifetime Access18 Foundation lessons are free, no payment needed. Try them now
It is easy and good
“It is really nice and good Please join the course”
You need to book a flight. Instead of checking one airline at a time, you go to a comparison site like Kayak or Skyscanner. It sends your search to 50 airlines simultaneously, waits for responses, and shows you the cheapest option.
That's scatter-gather. It broadcasts the same request to multiple services (scatter), collects all the responses (gather), and selects or combines the best result.
Scatter-gather looks like fan-out/fan-in, but the intent is different. Fan-out/fan-in splits one task into subtasks, each worker processes a different piece of the data. Scatter-gather sends the same request to multiple providers, each independently produces a complete answer, and the aggregator chooses the best.
Price comparison engines, insurance quote aggregators, load balancers probing backend health, distributed search across heterogeneous data sources: all scatter-gather. Google's Bigtable read path scatters a read request to all replicas and takes the first response. Kayak scatters to 500+ airlines and hotel providers simultaneously. AWS Route 53 health checks scatter ping requests to your endpoints from multiple regions and gather the results to determine health.
Scatter: The coordinator broadcasts the same request to all target services. Every provider gets an identical copy.
Gather: The coordinator collects responses within a timeout window, then applies a selection or aggregation strategy.
Gathering strategies:
| Strategy | Description | Use Case |
|---|---|---|
| Best result | Pick the lowest price, highest score, fastest response | Price comparison, optimization |
| First response | Use whatever comes back first | Read from closest replica |
| Majority | Use the answer most services agree on | Distributed consistency ( reads) |
| Union | Combine all unique results | Distributed search across heterogeneous indexes |
| Weighted average | Average responses with configurable weights | Risk scoring, credit rating aggregation |
The timeout problem. You can't wait forever. Set a deadline. If Airline C doesn't respond in 2 seconds, return results from the other airlines. The user gets a slightly incomplete but fast result, rather than staring at a spinner for 30 seconds waiting for one slow provider.
Skyscanner's engineering blog describes their approach: an initial 2-second window returns "instant results" from fast providers. A background process continues gathering for up to 30 seconds, appending results as they arrive. The UI shows "more results loading..." and refreshes dynamically. This two-phase gather gives users fast feedback without sacrificing completeness.
The thundering herd risk. Scattering to 500 providers simultaneously means 500 outbound requests in a single burst. If your coordinator runs on 100 servers and each scatters to 500 providers, you generate 50,000 requests in an instant. on the scatter side is not optional. Stagger requests, use connection pooling, and respect provider rate limits.