Last active
May 11, 2022 09:29
-
-
Save rinov/89f99f0d41bc25d1e4e0d78e446d5bd1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
def exponential_backoff_and_jitter(n): | |
""" | |
Exponential Backoff And Jitter Algorithm (Full Jitter) | |
:param n: Retry number of times | |
:return: Retry interval (ms) | |
""" | |
backoff = pow(2, n) * 1000 | |
return backoff + random.randint(0, backoff) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment