How do I configure timeouts?
Attention
This is not an exhaustive list of all of the configurable timeouts that Envoy supports. Depending on the deployment additional configuration may be required.
Connection timeouts apply to the entire HTTP connection and all streams the connection carries.
The HTTP protocol idle_timeout is defined in a generic message used by both the HTTP connection manager as well as upstream cluster HTTP connections. The idle timeout is the time at which a downstream or upstream connection will be terminated if there are no active streams. The default idle timeout if not otherwise specified is 1 hour. To modify the idle timeout for downstream connections use the field in the HTTP connection manager configuration. To modify the idle timeout for upstream connections use the common_http_protocol_options field in the Cluster’s , keyed by envoy.extensions.upstreams.http.v3.HttpProtocolOptions
The HTTP protocol max_connection_duration is defined in a generic message used by both the HTTP connection manager as well as upstream cluster HTTP connections but is currently only implemented for the downstream connections. The maximum connection duration is the time after which a downstream connection will be drained and/or closed, starting from when it first got established. If there are no active streams, the connection will be closed. If there are any active streams, the drain sequence will kick-in, and the connection will be force-closed after the drain period. The default value of max connection duration is 0 or unlimited, which means that the connections will never be closed due to aging. It could be helpful in scenarios when you are running a pool of Envoy edge-proxies and would want to close a downstream connection after some time to prevent sticky-ness. It could also help to better load balance the overall traffic among this pool, especially if the size of this pool is dynamically changing. To modify the max connection duration for downstream connections use the field in the HTTP connection manager configuration.
See below for other connection timeouts.
Stream timeouts apply to individual streams carried by an HTTP connection. Note that a stream is an HTTP/2 and HTTP/3 concept, however internally Envoy maps HTTP/1 requests to streams so in this context request/stream is interchangeable.
The HTTP connection manager is the amount of time the connection manager will allow for the entire request stream to be received from the client.
This timeout is not enforced by default as it is not compatible with streaming requests (requests that never end). See the stream idle timeout that follows. However, if using the buffer filter, it is recommended to configure this timeout.
The HTTP connection manager determines the amount of time the client has to send only the headers on the request stream before the stream is cancelled. This can be used to prevent clients from consuming too much memory by creating large numbers of mostly-idle streams waiting for headers. The request header timeout is disabled by default.
The HTTP connection manager stream_idle_timeout is the amount of time that the connection manager will allow a stream to exist with no upstream or downstream activity. The default stream idle timeout is 5 minutes. This timeout is strongly recommended for all requests (not just streaming requests/responses) as it additionally defends against a peer that does not open the stream window once an entire response has been buffered to be sent to a downstream client.
The HTTP protocol is defined in a generic message used by the HTTP connection manager. The max stream duration is the maximum time that a stream’s lifetime will span. You can use this functionality when you want to reset HTTP request/response streams periodically. You can’t use request_timeout in this situation because this timer will be disarmed if a response header is received on the request/response streams. This timeout is available on both upstream and downstream connections.
Envoy supports additional stream timeouts at the route level, as well as overriding some of the stream timeouts already introduced above.
The route can be configured when using retries so that individual tries using a shorter timeout than the overall request timeout described above. This timeout only applies before any part of the response is sent to the downstream, which normally happens after the upstream has sent response headers. This timeout can be used with streaming endpoints to retry if the upstream fails to begin a response within the timeout.
The route per_try_idle_timeout can be configured to ensure continued response progress of individual retry attempts (including the first attempt). This is useful in cases where the total upstream request time is bounded by the number of attempts multiplied by the per try timeout, but while the user wants to ensure that individual attempts are making progress.
The route can be used to override the HttpConnectionManager’s max_stream_duration for individual routes as well as setting both limits and a fixed time offset on grpc-timeout headers.
In situations where envoy is under high load, Envoy can dynamically configure timeouts using scaled timeouts. Envoy supports scaled timeouts through the , configured in envoy bootstrap configuration. Using a overload action, the Overload Manager can be configured to monitor resources and scale timeouts accordingly. For example, a common use case may be to monitor the Envoy and set the scaled TimerType to HTTP_DOWNSTREAM_CONNECTION_IDLE. The overload manager will scale down the once the scaling_threshold has been met and will set the timeout to the once the scaling_threshold is met. The full list of supported timers that can be scaled is available in the overload manager .
The cluster connect_timeout specifies the amount of time Envoy will wait for an upstream TCP connection to be established. If this value is not set, a default value of 5 seconds will be used.
Attention
For upstream TLS connections, the connect timeout includes the TLS handshake. For downstream connections, see for configuration options.
The TCP proxy idle_timeout is the amount of time that the TCP proxy will allow a connection to exist with no upstream or downstream activity. The default idle timeout if not otherwise specified is 1 hour.