Sends the same work again before the first one has failed, and takes the
first answer.
A retry waits for a failure; a slow call is not a failure, and waiting for
one is how a p99 becomes a timeout. A hedge starts a second attempt once the
first has taken too long, keeps both running, and abandons the losers as
soon as one answers, which works here because every attempt already gets
its own signal, so the losers are cancelled rather than left running.
It costs the dependency an extra call whenever it is slow, so it belongs on
reads and on anything else that can be repeated safely. firefly/http
refuses to hedge a request whose body cannot be replayed, for the same
reason it refuses to retry one.
If every attempt fails, the last failure is rethrown as it was.
Sends the same work again before the first one has failed, and takes the first answer.
A retry waits for a failure; a slow call is not a failure, and waiting for one is how a p99 becomes a timeout. A hedge starts a second attempt once the first has taken too long, keeps both running, and abandons the losers as soon as one answers, which works here because every attempt already gets its own signal, so the losers are cancelled rather than left running.
It costs the dependency an extra call whenever it is slow, so it belongs on reads and on anything else that can be repeated safely.
firefly/httprefuses to hedge a request whose body cannot be replayed, for the same reason it refuses to retry one.If every attempt fails, the last failure is rethrown as it was.