# Scatter-Gather

> Blast a request to N services in parallel, collect all responses, pick the best.

- **Category**: Integration
- **Subcategory**: Message Routing
- **Canonical URL**: https://designpattern.fyi/patterns/scatter_gather/

---

## Description
Clean, reusable architecture pattern.


## Use Cases
Flight search — query sent to 8 airline APIs simultaneously. Each returns available flights. Aggregator collects responses for 3 seconds, then emits a combined FlightSearchResults message. Slowest airline misses the cutoff but the user still gets results fast from the 7 that responded.





## Trade-offs


### Advantages

- Maximum parallelism — all recipients process simultaneously

- Timeout-based gather gives results even if some recipients are slow

- Clean separation of scatter (broadcast) and gather (aggregate) concerns

- Best-of-N selection — pick the fastest, cheapest, or most relevant result




### Considerations & Drawbacks

- All recipients get the request regardless of relevance — can cause load

- Aggregation complexity — partial results, timeout handling, result ranking

- Correlation ID management across N concurrent flows

- All-or-nothing vs best-effort gather semantics must be explicitly designed







---
**Reference**: [Original Source](https://www.enterpriseintegrationpatterns.com/patterns/messaging/BroadcastAggregate.html)

