When to Use the Promise.any() method
Discover how Promise.any() executes hedge requests, and choose the fastest service.
We'll cover the following
The Promise.any()
method is best used in situations where we want any one of the promises to fulfill
, regardless of how many others reject
, unless they all reject
. Here are some situations where we might want to use Promise.any()
.
Executing hedged requests
A hedged request is one where the client makes requests to multiple servers and accepts the response from the first that replies. This is helpful in situations where the client needs the lowest latency possible and there are server resources devoted to managing the extra load and deduplicating responses. Here’s an example:
Get hands-on with 1400+ tech skills courses.