-
Notifications
You must be signed in to change notification settings - Fork 709
Description
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
timeoutis disabled,idle_timeoutis disabled - if the route's
timeoutis greater than 1hr, theidle_timeoutis increased totimeout.
gateway/internal/xds/translator/route.go
Lines 384 to 401 in ed5e7e4
| 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
- when CTP
stream_idle_timeoutis configured, avoid auto-configuration the route'sidle_timeout, and allow the HCM-level value to win. - Make
idle_timeoutconfigurable through BTP
Relevant Links:
https://www.envoyproxy.io/docs/envoy/latest/faq/configuration/timeouts