Skip to content

Envoy Gateway Requests Timing Out After 15 Seconds: HTTPRoute and BackendTrafficPolicy

Interactive Diagram

새 탭 ↗

A backend can still be processing a request when the gateway returns 504 Gateway Timeout. If the response body says upstream request timeout and requests repeatedly fail after roughly the same duration, check the limits along the request path before restarting Pods.

Some APIs may still time out early after you increase the shared Gateway limit. An explicit HTTPRoute value or a more specific policy can make the shared change ineffective. This post shows how to find that value and adjust the timeout only where it is needed.

The baseline is Envoy Gateway v1.9.0. Installation and Gateway configuration are covered in Envoy Gateway Setup; this post focuses on timeouts along an already working HTTP path.

Symptoms: which layer ended the request first?

Section titled “Symptoms: which layer ended the request first?”

The client, gateway, and backend can each end a request. Seeing continued processing in backend logs does not establish that the rest of the path is healthy.

What to inspectWhat to look for
Client outputAn HTTP 504 versus the client exiting without an HTTP response
Gateway access logStatus code and timeout-related details for the same request
Backend logsWhether it received the request and when it completed the response
A call bypassing the gatewayWhether the backend itself fails after the same duration

Envoy Proxy’s default Route timeout is 15 seconds. This is not a universal Gateway API default. Gateway API leaves behavior for unspecified timeouts to the implementation.

Separate client, gateway, and backend limits along the same request path

Figure 1. More than one layer can end a request. Original diagram based on Envoy’s timeout explanation and Istio’s request timeout explanation.

A limit on total request duration differs from a limit on the time without data. Connection establishment has its own limit too.

SettingWhat it limits
HTTPRoute.rules[].timeouts.requestTotal time for the gateway to process a request and send its response
HTTPRoute.rules[].timeouts.backendRequestAn individual request from the gateway to a backend
BackendTrafficPolicy.spec.timeout.http.requestTimeoutThe policy’s limit for completing the upstream response
BackendTrafficPolicy.spec.timeout.tcp.connectTimeoutEstablishing the backend connection
BackendTrafficPolicy.spec.timeout.http.streamIdleTimeoutTime without request or response data on a stream
BackendTrafficPolicy.spec.timeout.http.maxStreamDurationMaximum lifetime of a stream

request and backendRequest are not alternate spellings of the same setting. With retries, one overall request can contain several backend requests. When both values are finite, backendRequest cannot exceed request.

In v1.9.0, processRouteTimeout uses backendRequest as the final Route timeout when it is set on a rule without retries. To avoid mixing these cases, the ordinary API examples here set only request.

The official AKS Istio add-on ingress example uses Istio’s Gateway and VirtualService. The names resemble Envoy Gateway’s Gateway API resources, but their API groups differ.

ItemEnvoy GatewayAKS Istio ingress using Istio APIs
Gateway resourceGateway in gateway.networking.k8s.ioGateway in networking.istio.io
HTTP routingHTTPRouteVirtualService
Request timeoutHTTPRoute timeouts or BackendTrafficPolicyVirtualService.http[].timeout
Default request limitEnvoy Route default of 15 secondsDisabled by default in the Istio documentation

Both use Envoy, but the controlling products apply different defaults. Having no explicit timeout in Istio does not mean an Envoy Gateway route will have no limit.

The equivalent Istio setting looks like this. The slow-api Service and ingress Gateway are assumed to exist already.

istio-slow-api.yaml
apiVersion: networking.istio.io/v1
kind: VirtualService
metadata:
name: slow-api
spec:
hosts:
- timeout.example.com
gateways:
- ingress-gateway
http:
- route:
- destination:
host: slow-api
port:
number: 3000
timeout: 30s

This comparison covers request limits for ingress using Istio APIs. For AKS add-on installation and mesh policies, see the official AKS ingress guide.

Assume Gateway eg and a delay-capable Service named backend exist in the default namespace. This is the same kind of backend used in Envoy Gateway’s official timeout guide. Set GATEWAY_URL to the HTTP address through which you can reach the Gateway.

The following Route allows four seconds for the request.

slow-api-route.yaml
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: slow-api
namespace: default
spec:
parentRefs:
- name: eg
hostnames:
- timeout.example.com
rules:
- matches:
- path:
type: PathPrefix
value: /
backendRefs:
- name: backend
port: 3000
timeouts:
request: "4s"
Terminal window
kubectl apply -f slow-api-route.yaml
curl -sS -i --max-time 10 \
-H 'Host: timeout.example.com' "$GATEWAY_URL/?delay=3s"

A three-second response delay is shorter than the four-second limit, so the request should succeed. Reducing the limit to two seconds lets you observe a gateway timeout.

Terminal window
kubectl patch httproute slow-api -n default --type=json \
-p '[{"op":"replace","path":"/spec/rules/0/timeouts/request","value":"2s"}]'

After the change, the official guide’s expected response for the same request is:

HTTP/1.1 504 Gateway Timeout
...
upstream request timeout

If curl --max-time is shorter than the gateway limit, the client exits first and hides this behavior. The example sets it to ten seconds to distinguish the two limits.

Shared defaults and exceptions with BackendTrafficPolicy

Section titled “Shared defaults and exceptions with BackendTrafficPolicy”

Attach a policy to the Gateway when several Routes need a shared limit. This example sets a 60-second request limit for Routes attached to eg.

gateway-timeout-policy.yaml
apiVersion: gateway.envoyproxy.io/v1alpha1
kind: BackendTrafficPolicy
metadata:
name: gateway-timeout
namespace: default
spec:
targetRefs:
- group: gateway.networking.k8s.io
kind: Gateway
name: eg
timeout:
http:
requestTimeout: 60s

For a 30-second limit on slow-api alone, target that HTTPRoute with a separate policy.

route-timeout-policy.yaml
apiVersion: gateway.envoyproxy.io/v1alpha1
kind: BackendTrafficPolicy
metadata:
name: slow-api-timeout
namespace: default
spec:
targetRefs:
- group: gateway.networking.k8s.io
kind: HTTPRoute
name: slow-api
timeout:
http:
requestTimeout: 30s

A policy must be in the same namespace as its target. Both the Gateway and HTTPRoute above are in default, so both policies belong there too. If the application Route is in another namespace, create its Route-targeted policy in that namespace.

More specific scopes take precedence: Route rule, Route, Gateway listener, then the whole Gateway. This post covers HTTPRoutes attached directly to a Gateway.

Without mergeType, the most specific policy is selected without automatically merging it with its parent. A Route policy containing only a timeout does not necessarily retain the Gateway policy’s other limits. If parent configuration must be combined, check the behavior of StrategicMerge or JSONMerge too.

Activity diagram selecting an explicit HTTPRoute timeout, otherwise a policy value, then the Envoy default

Figure 2. PlantUML activity diagram generated from timeout-precedence.puml. An explicit HTTPRoute value ends the selection before the policy request limit is considered. Policy scopes and mergeType are explained in the note below the flow. Original diagram based on the BackendTrafficPolicy documentation and the v1.9.0 translator code.

The earlier example set timeouts.request: "2s" on slow-api. While that value remains, applying the policies above does not change the request limit to 30 seconds.

In v1.9.0, getEffectiveRequestTimeout first uses the timeout translated from HTTPRoute. Only if that value is absent does it use the selected BackendTrafficPolicy’s request timeout. The same release’s timeout test output shows a final value of ten seconds when HTTPRoute specifies ten and the policy specifies five.

To manage the value through policies, remove timeouts from the Route before applying them.

Terminal window
kubectl patch httproute slow-api -n default --type=json \
-p '[{"op":"remove","path":"/spec/rules/0/timeouts"}]'
kubectl apply -f gateway-timeout-policy.yaml
kubectl apply -f route-timeout-policy.yaml

A controller generating Routes may put the field back. Adjust its generation settings or consider changing the Route’s owner, as described in Managing KServe HTTPRoutes.

If requests still time out: inspect the actual Envoy configuration

Section titled “If requests still time out: inspect the actual Envoy configuration”

First inspect the accepted Kubernetes resources and their status conditions.

Terminal window
kubectl get httproute slow-api -n default -o yaml
kubectl get backendtrafficpolicy -n default -o yaml

Check Accepted and ResolvedRefs in HTTPRoute’s status.parents[].conditions, then read the policy conditions too. Confirm the target name, namespace, and kind, and whether observedGeneration reflects the resource’s current generation. A successful kubectl apply is not proof of data-plane application.

Next use the matching version of egctl to read the actual Envoy Route configuration.

Terminal window
egctl config envoy-proxy route | jq '
.. | objects
| select(.match? != null and .route? != null)
| {
name,
timeout: .route.timeout,
idleTimeout: .route.idleTimeout,
maxStreamDuration: .route.maxStreamDuration
}'

The list includes internal management Routes, so locate the relevant HTTPRoute using name. A null timeout means the field was omitted from the dump, not that the limit is disabled. Distinguish an explicit 0s from use of the default.

The following are expected behaviors based on the official delayed-response example and v1.9.0 source.

ConditionExpected behavior
No request timeout configured, response takes 20 secondsHits Envoy’s default 15-second request limit
HTTPRoute request: 4s, response takes 3 secondsSuccess
HTTPRoute request: 2s, response takes 3 secondsGateway timeout
No HTTPRoute timeout, Gateway policy specifies 60 secondsFinal request limit of 60 seconds
No HTTPRoute timeout, Gateway policy specifies 60 and Route policy specifies 30 secondsRoute policy’s 30 seconds
HTTPRoute request: 4s, policy request limit of 30 secondsHTTPRoute’s four seconds
Gateway limit of 30 seconds, client limit of 10 secondsClient exits first

If configuration and actual behavior disagree, compare application-server, additional proxy, and client limits for the same request.

An inference API that returns one complete response and a streaming API that sends tokens incrementally often need different policies.

Envoy’s Route timeout starts after the entire downstream request is received and limits the time until the upstream response completes. A response can therefore keep streaming yet still hit the overall limit. An endless streaming request has a different timer start condition, so check maxStreamDuration and idle limits instead.

Two limits can be separated for streaming APIs:

  • streamIdleTimeout cleans up a stream without further data. If data keeps arriving, this limit alone does not bound its total duration.
  • maxStreamDuration limits the entire stream even while data continues to arrive.

For example, if a separate stream-api Route exists, attach this policy to it.

stream-timeout-policy.yaml
apiVersion: gateway.envoyproxy.io/v1alpha1
kind: BackendTrafficPolicy
metadata:
name: stream-api-timeout
namespace: default
spec:
targetRefs:
- group: gateway.networking.k8s.io
kind: HTTPRoute
name: stream-api
timeout:
http:
requestTimeout: 0s
streamIdleTimeout: 30s
maxStreamDuration: 600s

If stream-api still has a finite timeouts.request or backendRequest, that value takes precedence over the policy’s requestTimeout: 0s. This example assumes no built-in HTTPRoute timeout remains.

Thirty and 600 seconds are illustrative settings, not fixed recommendations. Choose values using normal data intervals, time to the first response, cancellation handling, and resource occupancy. If response headers have already been sent, a timeout may appear as a stream ending or reset rather than a new HTTP 504.

  • Separate ordinary and long-running APIs by Route. Check the affected scope before increasing a shared Gateway limit across the board.
  • Decide whether HTTPRoute or policies own request timeouts. Maintaining them in both places can make shared policy changes ineffective.
  • Inspect final Route dumps and request results, not just configuration values. Verify application cancellation and cleanup so unnecessary work does not continue after the timeout.
  • The precedence described here is for v1.9.0. ListenerSet, retry and fault-injection combinations, and dynamic overload limits are outside the scope.