4 ms·
Sleeping on error is a valid pattern when combined with retries. Agreed. Just note that it can sometimes (often?) be a good idea to add a small stochastic elem
by mindcrime 3y ago
Sleeping on error is a valid pattern when combined with retries.
Agreed. Just note that it can sometimes (often?) be a good idea to add a small stochastic element to the sleep time, and/or do something similar to the exponential back-off[1] approach that Ethernet (among other things) uses.
[1]: https://en.wikipedia.org/wiki/Exponential_backoff https://en.wikipedia.org/wiki/Exponential_backoff
- tylerhou 3y agoYou ideally want both exponential back off plus some random delay (to prevent thundering herd).
- chrsig 3y agoI've never personaly seen any benefit from exponential backoff... constant backoff + jitters + short timeouts has always worked well for me. If anything, people underestimating the ramp up of exponential back off(or not capping it) has left me waiting much longer than necessary
- justcool393 3y agothe amount of times something (Discord is the first example that comes to mind) starts waiting 30 seconds between retries because I wasn't connected to the network has been super absurd.