Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ananth7592
Copy link
Contributor

@ananth7592 ananth7592 commented Mar 5, 2025

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

  • 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.

Example Customer use-cases

  1. 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.

  2. 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.

  • [] Bug fix (non-breaking change which fixes an issue)
  • [] New feature (non-breaking change which adds functionality)
  • [] Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • [] This change requires a documentation update

Closing issues

To automatically close an issue: closes #IssueNumber

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good!

@ananth7592 ananth7592 changed the title Enhancement: Configurable First Retry Timeout for HTTP Calls Enhancement: Adds Configurable First Retry Timeout for HTTP Calls Mar 5, 2025
@ananth7592 ananth7592 force-pushed the ananth/add-timeout-retry branch 2 times, most recently from 522ecea to c845e0e Compare March 11, 2025 20:53
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(
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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?

Copy link
Contributor Author

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)

@ananth7592 ananth7592 force-pushed the ananth/add-timeout-retry branch 2 times, most recently from 4887439 to f4c738e Compare March 18, 2025 00:49
- 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.
@ananth7592 ananth7592 force-pushed the ananth/add-timeout-retry branch from f4c738e to 116b0c6 Compare March 25, 2025 22:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants