How does exponential backoff work? #3252
-
Ethers Version5.6.9 Search Termsweb Describe the ProblemAccording to the documentation for throttleSlotInterval
The current implementation seems to be a bit unpredictable since further attempts will potentially generate a stall time of 0. 100 * parseInt(String(Math.random() * Math.pow(2, 3)))
200
100 * parseInt(String(Math.random() * Math.pow(2, 3)))
0
100 * parseInt(String(Math.random() * Math.pow(2, 3)))
100 I would have expected the implementation to be something similar to:
Any thoughts? Code SnippetNo response Contract ABINo response ErrorsNo response EnvironmentNo response Environment (Other)No response |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
"A bit unpredictable" is the exact purpose of exponential backoff. :) The goal of it is to handle situations of congestion... If too many connections were attempted at some time X, and everyone was told to wait 100ms and try again, you would then get the same too many connections re-trying at time X + 100. But having approximately 50% of them retry at time X + 0 and 50% at time X + 100 you increase the chances of the congestion being unclogged. If not, then a further knock at 25% X + 0, 25% at X + 100, another 25% at X + 200 and the remaining 25% at X + 300. And so on. For more information on the awesome properties and rationale, check out Exponential Back-off on Wikipedia. :) |
Beta Was this translation helpful? Give feedback.
"A bit unpredictable" is the exact purpose of exponential backoff. :)
The goal of it is to handle situations of congestion... If too many connections were attempted at some time X, and everyone was told to wait 100ms and try again, you would then get the same too many connections re-trying at time X + 100. But having approximately 50% of them retry at time X + 0 and 50% at time X + 100 you increase the chances of the congestion being unclogged. If not, then a further knock at 25% X + 0, 25% at X + 100, another 25% at X + 200 and the remaining 25% at X + 300. And so on.
For more information on the awesome properties and rationale, check out Exponential Back-off on Wikipedia. :)