Skip to content

Commit f3e9ece

Browse files
authored
docs: fix the timeout behavior explanation (#41783)
1 parent 0487b44 commit f3e9ece

File tree

1 file changed

+39
-14
lines changed

1 file changed

+39
-14
lines changed

docs/root/faq/configuration/timeouts.rst

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,17 @@ Connection timeouts apply to the entire HTTP connection and all streams the conn
2323

2424
* The HTTP protocol :ref:`idle_timeout <envoy_v3_api_field_config.core.v3.HttpProtocolOptions.idle_timeout>`
2525
is defined in a generic message used by both the HTTP connection manager as well as upstream
26-
cluster HTTP connections. The idle timeout is the time at which a downstream or upstream
27-
connection will be terminated if there are no active streams. The default idle timeout if not
28-
otherwise specified is *1 hour*. To modify the idle timeout for downstream connections use the
29-
:ref:`common_http_protocol_options
26+
cluster HTTP connections. The idle timeout is defined as the period in which there are no active
27+
requests or streams at the HTTP protocol layer. This timeout is independent of TCP-level activity
28+
such as TCP keepalive packets. When the idle timeout is reached, the connection will be closed.
29+
For HTTP/2 downstream connections, when idle timeout is reached, a drain sequence begins immediately,
30+
lasting for the configured :ref:`drain_timeout
31+
<envoy_v3_api_field_extensions.filters.network.http_connection_manager.v3.HttpConnectionManager.drain_timeout>`
32+
period (see below). For other connection types, the connection terminates directly. Note that idle
33+
timeout only fires when there are no active streams, unlike :ref:`max_connection_duration
34+
<envoy_v3_api_field_config.core.v3.HttpProtocolOptions.max_connection_duration>` which can trigger
35+
while streams are active. The default idle timeout if not otherwise specified is *1 hour*. To modify
36+
the idle timeout for downstream connections use the :ref:`common_http_protocol_options
3037
<envoy_v3_api_field_extensions.filters.network.http_connection_manager.v3.HttpConnectionManager.common_http_protocol_options>`
3138
field in the HTTP connection manager configuration. To modify the idle timeout for upstream
3239
connections use the
@@ -35,20 +42,38 @@ Connection timeouts apply to the entire HTTP connection and all streams the conn
3542
* The HTTP protocol :ref:`max_connection_duration <envoy_v3_api_field_config.core.v3.HttpProtocolOptions.max_connection_duration>`
3643
is defined in a generic message used by both the HTTP connection manager as well as upstream cluster
3744
HTTP connections. The maximum connection duration is the time after which a downstream or upstream
38-
connection will be drained and/or closed, starting from when it was first established. If there are no
39-
active streams, the connection will be closed. If there are any active streams, the drain sequence will
40-
kick-in, and the connection will be force-closed after the drain period. The default value of max connection
41-
duration is *0* or unlimited, which means that the connections will never be closed due to aging. It could
42-
be helpful in scenarios when you are running a pool of Envoy edge-proxies and would want to close a
43-
downstream connection after some time to prevent stickiness. It could also help to better load balance the
44-
overall traffic among this pool, especially if the size of this pool is dynamically changing. Finally, it
45-
may help with upstream connections when using a DNS name whose resolved addresses may change even if the
46-
upstreams stay healthly. Forcing a maximum upstream lifetime in this scenario prevents holding onto healthy
47-
connections even after they would otherwise be undiscoverable. To modify the max connection duration for downstream connections use the
45+
connection will be drained and/or closed, starting from when it was first established. When max connection
46+
duration is reached, the drain sequence will kick in (see :ref:`drain_timeout
47+
<envoy_v3_api_field_extensions.filters.network.http_connection_manager.v3.HttpConnectionManager.drain_timeout>`
48+
below for details). After the drain timeout period elapses, if there are no active streams at that moment,
49+
the connection will be closed immediately. If active streams still exist at that moment, the connection
50+
remains open until all streams complete naturally, and then closes. The drain sequence does not forcefully
51+
terminate active streams. The default value of max connection duration is *0* or unlimited, which means that
52+
the connections will never be closed due to aging. It could be helpful in scenarios when you are running a
53+
pool of Envoy edge-proxies and would want to close a downstream connection after some time to prevent
54+
stickiness. It could also help to better load balance the overall traffic among this pool, especially if the
55+
size of this pool is dynamically changing. Finally, it may help with upstream connections when using a DNS
56+
name whose resolved addresses may change even if the upstreams stay healthy. Forcing a maximum upstream
57+
lifetime in this scenario prevents holding onto healthy connections even after they would otherwise be
58+
undiscoverable. To modify the max connection duration for downstream connections use the
4859
:ref:`common_http_protocol_options <envoy_v3_api_field_extensions.filters.network.http_connection_manager.v3.HttpConnectionManager.common_http_protocol_options>`
4960
field in the HTTP connection manager configuration. To modify the max connection duration for upstream connections use the
5061
:ref:`common_http_protocol_options <envoy_v3_api_field_config.cluster.v3.Cluster.common_http_protocol_options>` field in the cluster configuration.
5162

63+
* The HTTP connection manager :ref:`drain_timeout
64+
<envoy_v3_api_field_extensions.filters.network.http_connection_manager.v3.HttpConnectionManager.drain_timeout>`
65+
is the time that Envoy will wait between sending an initial HTTP/2 "shutdown notification" (``GOAWAY`` frame
66+
with max stream ID) and a final GOAWAY frame. This grace period allows in-flight requests to be assigned
67+
stream IDs and prevents a race with the final GOAWAY frame. During this grace period, Envoy will continue
68+
to accept new streams. After the grace period elapses, a final GOAWAY frame is sent and Envoy will start
69+
refusing new streams. At that moment, if no active streams exist, the connection closes immediately. If
70+
active streams still exist, the connection remains open until all streams complete naturally,
71+
then closes. The drain sequence never forcefully terminates active streams. Draining occurs either when a
72+
connection hits the :ref:`idle_timeout <envoy_v3_api_field_config.core.v3.HttpProtocolOptions.idle_timeout>`,
73+
when :ref:`max_connection_duration <envoy_v3_api_field_config.core.v3.HttpProtocolOptions.max_connection_duration>`
74+
is reached, or during general server draining. The default grace period is *5000 milliseconds (5 seconds)*
75+
if this option is not specified.
76+
5277
See :ref:`below <faq_configuration_timeouts_transport_socket>` for other connection timeouts.
5378

5479
Stream timeouts

0 commit comments

Comments
 (0)