Grokking Concurrency in Go
0% completed
Hedged Requests
Output:
page from request 2 <nil> after 150ms request 1: canceled request 2: answered
Request 1 goes to a server that needs 300 ms. After 100 ms without an answer, hedged sends the same request again, and the second copy answers 50 ms later. The caller gets its page after 150 ms instead of 300 ms. Request 1 is canceled as soon as request 2 wins.
That is a hedged request: a second copy of a request, sent only when the first is slower than usual. The first answer is used and the other copy is canceled
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%