Skip to content

Rethink Route Idle Timeout Autoconfig #7806

@guydc

Description

@guydc

Description:

Background

Currently, Envoy Gateway will auto-configure idle_timeout only if the route's timeout is configured.

  • The default value is 1hr
  • If the route's timeout is disabled, idle_timeout is disabled
  • if the route's timeout is greater than 1hr, the idle_timeout is increased to timeout.

func idleTimeout(httpRoute *ir.HTTPRoute) *durationpb.Duration {
rt := getEffectiveRequestTimeout(httpRoute)
timeout := time.Hour // Default to 1 hour
if rt != nil {
// Ensure is not less than the request timeout
if timeout < rt.Duration {
timeout = rt.Duration
}
// Disable idle timeout when request timeout is disabled
if rt.Duration == 0 {
timeout = 0
}
return durationpb.New(timeout)
}
return nil
}

This seems to contradict recommendations from the Envoy proxy project to use stream_idle_timeout/route.idle_timeout when route.timeout is disabled.

A route timeout is the amount of time that Envoy will wait for the upstream to respond with a complete response. This timeout does not start until the entire downstream request stream has been received.

Attention

This timeout defaults to 15 seconds, however, it is not compatible with streaming responses (responses that never end), and will need to be disabled. Stream idle timeouts should be used in the case of streaming APIs as described elsewhere on this page.

Recommendation appears to be: use stream_idle_time instead of timeout when streaming: instead of timing out if request/response take too long, time out when the stream become inactive.

The route's idle_timeout overrides stream_idle_timeout:

The route idle_timeout allows overriding of the HTTP connection manager stream_idle_timeout and does the same thing.

This logic was added in #2708 to improve conformance with GW-API, which doesn't distinguish between these two different timeouts.

Envoy Gateway also support the stream_idle_timeout option in ClientTrafficPolicy. However, since idle_timeout overrides stream_idle_timeout, route timeouts can have an unexpected side-effect of canceling the explicitly-configured stream_idle_timeout.

Users may want, for security and resource management reasons, to disable route timeout in long-running streaming connections, but enforce some sort of stream_idle_timeout/idle_timeout.

Options

  1. when CTP stream_idle_timeout is configured, avoid auto-configuration the route's idle_timeout, and allow the HCM-level value to win.
  2. Make idle_timeout configurable through BTP

Relevant Links:

https://www.envoyproxy.io/docs/envoy/latest/faq/configuration/timeouts

Metadata

Metadata

Assignees

Labels

area/apiAPI-related issues

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions