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

Make cancelation configurable #319

Closed
samsp-msft opened this issue Jul 9, 2020 · 10 comments
Closed

Make cancelation configurable #319

samsp-msft opened this issue Jul 9, 2020 · 10 comments
Assignees
Labels
Type: Bug Something isn't working

Comments

@samsp-msft
Copy link
Contributor

[Re-filing as I screwed up and converted to a discussion when I did it in the wrong tab. Originally #293]

Offline feedback from the StackOverflow team.

Two cancellation tokens are used when proxying requests, a short one and a long one.

// TODO: Configurable timeout, measure from request start, make it unit-testable
shortCts.CancelAfter(TimeSpan.FromSeconds(30));
// TODO: Retry against other destinations
try
{
// TODO: Apply caps
cluster.ConcurrencyCounter.Increment();
destination.ConcurrencyCounter.Increment();
// TODO: Duplex channels should not have a timeout (?), but must react to Proxy force-shutdown signals.
var longCancellation = context.RequestAborted;

The short token defaults to a 30 second timeout and is not currently configurable. This tracks the amount of time the destination has to respond with headers (not body). It's also linked to the long token.

  • This timeout should be configurable globally
  • Should there be a way to override it per route or cluster?

The long token is actually the HttpContext.RequestAborted token. It's used to track the response body. This tells the destination to abort if the client disconnects.

  • Does this need to be configurable in any way?
  • Should there also be a timeout applied to this part of the request? Configurable at what level?
  • Timeouts on the body don't work well for varying sized responses, or for streaming scenarios.
  • Middleware could add its own timeouts per request by augmenting RequestAborted.
@samsp-msft samsp-msft added the Type: Bug Something isn't working label Jul 9, 2020
@samsp-msft
Copy link
Contributor Author

@scalablecory, @alnikola - why does the 30s timeout seem familiar for something baked into the networking stack?

@Tratcher Tratcher added this to the 1.0.0 milestone Jul 9, 2020
@davidni
Copy link
Contributor

davidni commented Jul 9, 2020

Should there be a way to override it per route or cluster?

Yes! :). We recently implemented configurability at the Cluster level by adding a top level property ProxyTimeout on ClusterConfig. Being able to set it per route would also be useful. Order of precedence IMHO should be RouteConfig --> ClusterConfig --> Global value.

@davidni
Copy link
Contributor

davidni commented Jul 9, 2020

Related: When retries are implemented, it will be important to further distinguish timeout per attempt, and global timeout for all attempts.

Additional reading: Timeouts in Envoy, per_try_timeout

@scalablecory
Copy link

@scalablecory, @alnikola - why does the 30s timeout seem familiar for something baked into the networking stack?

Doesn't ring any bells to me. Could you be thinking of the ~60 second Socket.Connect() timeout in Windows?

@amweiss
Copy link
Contributor

amweiss commented Jul 10, 2020

Per-route would be ideal for our use cases, but per-cluster would be sufficient.

@NickCraver
Copy link
Member

Could we start with the global timeout and potentially do the others later on? The static 30 is causing constant issues for us, especially on first request when the app behind the proxy is spinning up.

@Tratcher
Copy link
Member

@NickCraver How about I start by bumping it to 100s to match HttpClient's traditional default?

@NickCraver
Copy link
Member

@Tratcher that would definitely help - practically speaking we wouldn't need to adjust it for the 95% case after that. Until we can configure it, that'd be a very welcomed change! /cc @deanward81

@Tratcher
Copy link
Member

@NickCraver ok, I'll tweak it in #406 for preview5 since I'm about to mess with timeouts anyways.

@ManickaP
Copy link
Member

Fixed in #512

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants