Retry Mechanism Explained
The retry mechanism uses a randomization function that grows exponentially. This formula and how the default values affect it is best described by the example below:
- 1st retry:
- Always a flat
initialRetryTime
ms - Default:
300ms
- Always a flat
- Nth retry:
- Formula:
Random(previousRetryTime * (1 - factor), previousRetryTime * (1 + factor)) * multiplier
- N = 1:
- Since
previousRetryTime == initialRetryTime
just plug the values in the formula: - Random(300 * (1 - 0.2), 300 * (1 + 0.2)) * 2 => Random(240, 360) * 2 => (480, 720) ms
- Hence, somewhere between
480ms
to720ms
- Since
- N = 2:
- Since
previousRetryTime
from N = 1 was in a range between 480ms and 720ms, the retry for this step will be in the range of: previousRetryTime = 480ms
=> Random(480 * (1 - 0.2), 480 * (1 + 0.2)) * 2 => Random(384, 576) * 2 => (768, 1152) mspreviousRetryTime = 720ms
=> Random(720 * (1 - 0.2), 720 * (1 + 0.2)) * 2 => Random(576, 864) * 2 => (1152, 1728) ms- Hence, somewhere between
768ms
to1728ms
- Since
- And so on...
- Formula: