Skip to content

Commit

Permalink
make UMAPI request backoff really exponential
Browse files Browse the repository at this point in the history
  • Loading branch information
kwin committed Jun 11, 2024
1 parent 6701609 commit 1ce1dcb
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ public class IMSUserManagement implements ExternalGroupManagement {
*
*/
static final class TooManyRequestsRetryStrategy implements ServiceUnavailableRetryStrategy {
private static final double DEFAULT_MULTIPLIER = 1.5; // increases each time by 50%
private final int maxRetryCount;
private final int defaultRetryDelayInSeconds;
private long retryDelayInMilliseconds;
Expand All @@ -134,7 +135,7 @@ public boolean retryRequest(HttpResponse response, int executionCount, HttpConte
LOG.info("Received 429 status with Retry-After header {}", retryAfterHeader.getValue());
}
// make it exponential because the retry-after is unreliable (particularly with multiple requests in parallel)
retryDelayInMilliseconds *= executionCount;
retryDelayInMilliseconds *= Math.pow(DEFAULT_MULTIPLIER, executionCount);
// always add some jitter between 0 and default delay in seconds
long jitter= random.nextInt(defaultRetryDelayInSeconds) * 1000l;
retryDelayInMilliseconds += jitter;
Expand Down

0 comments on commit 1ce1dcb

Please sign in to comment.