-
Notifications
You must be signed in to change notification settings - Fork 507
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhancement: Adds Configurable First Retry Timeout for HTTP Calls #5050
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All good!
Microsoft.Azure.Cosmos/src/HttpClient/HttpTimeoutPolicyControlPlaneRetriableHotPath.cs
Outdated
Show resolved
Hide resolved
Microsoft.Azure.Cosmos/src/HttpClient/HttpTimeoutPolicyControlPlaneRetriableHotPath.cs
Outdated
Show resolved
Hide resolved
522ecea
to
c845e0e
Compare
Microsoft.Azure.Cosmos/src/HttpClient/HttpTimeoutPolicyControlPlaneRetriableHotPath.cs
Outdated
Show resolved
Hide resolved
private HttpTimeoutPolicyControlPlaneRetriableHotPath(bool shouldThrow503OnTimeout) | ||
{ | ||
this.shouldThrow503OnTimeout = shouldThrow503OnTimeout; | ||
} | ||
|
||
private readonly IReadOnlyList<(TimeSpan requestTimeout, TimeSpan delayForNextRequest)> TimeoutsAndDelays = new List<(TimeSpan requestTimeout, TimeSpan delayForNextRequest)>() | ||
{ | ||
(TimeSpan.FromSeconds(.5), TimeSpan.Zero), | ||
(TimeSpan.FromMilliseconds(Helpers.GetEnvironmentVariable( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If custom configuration it-self is >5seconds then is second retry with <== first worth?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So if the customer chooses a value as high as 5 seconds, we wait for a timeout of 5 seconds the first time and 5 seconds the second time as well. That should be okay , right?
Also I am adding a minimum limit of 100ms to ensure the customer is not using a very low first timeout value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's expected if they configure >5 seconds?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then , the first retry is attempted after 5 seconds (unless there is a cancellationToken with a lesser duration cancelling the task) .
Then if the HTTP call still fails, the second retry kicks in at the 10th (+5 seconds)
4887439
to
f4c738e
Compare
- Added support for configuring the first HTTP call timeout in the HTTP retry stack via an environment variable "AZURE_COSMOS_SDK_HTTP_FIRST_RETRY_TIMEOUT_VALUE_MS - Default first timeout remains 500ms, ensuring backward compatibility. - Provides customers with greater control over retry behavior to better suit their application needs.
f4c738e
to
116b0c6
Compare
This update introduces the ability for customers to configure the first timeout value that the client waits before declaring an HTTP call as timed out. Once this timeout is reached, the exponential backoff retry strategy is triggered.
Changed Introduced
Example Customer use-cases
Increasing the first timeout (default: 500ms → custom value)
Useful when customers expect longer HTTP response times and want to allow the request more time to complete before triggering retries. This is particularly useful when the customer network topology is inherently causing their HTTP calls longer to materialize.
Reducing the first timeout (fail fast approach)
Helps customers fail fast by lowering the timeout below 500ms, ensuring that retries begin sooner and reducing overall request latency.
Pull Request Template
Description
Please include a summary of the change and which issue is fixed. Include samples if adding new API, and include relevant motivation and context. List any dependencies that are required for this change.
Type of change
Please delete options that are not relevant.
Closing issues
To automatically close an issue: closes #IssueNumber