Reduce retry attempts and adjust timeout configuration

Lowered MaxRetryAttempts from 6 to 4 and reduced the outer timeout to 60 seconds to align with the updated exponential backoff total of 32 seconds. These changes aim to improve efficiency and reduce unnecessary waiting time during transient failures.
This commit is contained in:
Sipke Schoorstra 2025-03-03 10:53:32 +01:00
parent 9d19db09cf
commit ed5649091d
No known key found for this signature in database
GPG key ID: 5C10502B28A4268F

View file

@ -265,13 +265,13 @@ public abstract class SendHttpRequestBase : Activity<HttpResponseMessage>
.Handle<TimeoutException>() // Specific timeout exception
.Handle<HttpRequestException>(ex => IsTransientStatusCode(ex.StatusCode)) // Network errors or transient HTTP codes
.HandleResult(response => IsTransientStatusCode(response.StatusCode)),
MaxRetryAttempts = 6,
MaxRetryAttempts = 4,
UseJitter = false, // If enabled, adds a random value between -25% and +25% of the calculated Delay, except if BackoffType is Exponential, where a DecorrelatedJitterBackoffV2 formula is used for jitter calculation. That formula is based on Polly.Contrib.WaitAndRetry.
Delay = TimeSpan.FromSeconds(1),
BackoffType = DelayBackoffType.Exponential // Delay * 2^AttemptNumber, e.g. [ 2s, 4s, 8s, 16s, 32s, 64s ]. Total secs: 2 + 4 + 8 + 16 + 32 + 64 = 128s.
BackoffType = DelayBackoffType.Exponential // Delay * 2^AttemptNumber, e.g. [ 2s, 4s, 8s, 16s ]. Total secs: 2 + 4 + 8 + 16 = 32.
// If BackoffType is Exponential, then the calculated Delay is multiplied by a random value between -25% and +25% of the calculated Delay, except if BackoffType is Exponential, where a DecorrelatedJitterBackoffV2 formula is used for jitter calculation. That formula is based on Polly.Contrib.WaitAndRetry.
})
.AddTimeout(TimeSpan.FromSeconds(128 + 60)); // Outer timeout. 128 secs plus grace period for the last attempt.
.AddTimeout(TimeSpan.FromSeconds(60)); // Outer timeout. 32 secs plus grace period of 28 secs for the last attempt.
return pipelineBuilder.Build();
}