Timeout Settings in Envoy Proxy
Envoy comes with different categories of timeouts, and using each timeout correctly is significant to get expected results.
Terminology
Let’s look at few definitions before we dive into timeout configurations.
Downstream Service — Service that sends requests to envoy and receive responses from envoy.
Upstream Service — Service that receives requests from envoy and sends responses to envoy.
For example, in the diagram below, Service A is downstream and Service B is upstream of envoy proxy.
Timeout Configurations
Idle Timeout
Amount of time the connection will remain open with no activity on that connection. Since envoy manages connection with both downstream and upstream, this setting needs to be configured for both downstream and upstream connections.
Downstream Connection Idle Timeout — This timeout is controlled via common_http_protocol_options.idle_timeout setting under HttpConnectionManager filter in envoy. If not specified, this defaults to 1 hour.
Downstream Connection Idle timeout configuration example —
Upstream Connection Idle timeout — This setting controls when envoy closes the connection with upstream and it should be set correctly to avoid race conditions that result in 503 UF, UC errors.
Upstream Connection Idle timeout configuration example — Use common_http_protocol_options.idle_timeout under cluster setting to configure this value.
Connection Timeout
Amount of time envoy will wait for upstream connection to be established. This can be configured via cluster.connect_timeout setting.
Route Timeout/Response Timeout
Amount of time envoy will wait for upstream to respond with response. This setting can be configured per route. If not specified, this defaults to 15 seconds, which implies requests that take longer than 15s will fail with 504: Response Timeout errors.
Use route.timeout setting to configure route level timeout.
That’s it with all the essential timeout settings in envoy proxy. Once these timeouts are configured correctly, it makes your life easier while using envoy. Hope examples for these settings at one place would make it simpler to configure these timeouts.