spotify / completable-futures

Utilities for working with futures in Java 8

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow to fail fast when calling joinList.

JoseAlavez opened this issue · comments

Hi spotify devs.

We use this library in combination with Netty, to consume REST APIs that provide us with single fetch contracts (as for example GET /domain/resource/{id}). In other words, when we require to fetch a batch of resources by id, we create individual asynchronous HTTP calls to the respective APIs and then join the completable futures using .collect(CompletableFutures.joinList()).

When our app is under heavy load and our fetch batch logic leads to individual HTTP calls that grows dramatically, we are seeing execution times that are higher than the timeouts specified for each completable future. This is caused due to the capacity of our executor to perform each HTTP call (and queuing) but also because the current implementation of joinList and allAsList utilizes CompletableFuture#allOf, which will wait until all the stages are completed to either continue normally or exceptionally.

I coded a solution for the described matter in #68, but forgot to create an issue, so independently if my contribution gets accepted or not, maybe the improvement can still happen.

Cheers!

Closing as the only thing pending here is the merge of #68