I'm trying to use the x-envoy-upstream-rq-timeout-ms HTTP header to set request timeouts in Envoy. I am having trouble getting this to work in a service mesh configuration, in which requests is sent to an egress Envoy listener, which forwards to an ingress Envoy listener, which forwards it to a target upstream server.
The reason for this is that the egress Envoy listener
strips out the x-envoy-upstream-rq-timeout-ms, so the ingress Envoy listener never receives this header, which means that it will always use the default timeout. The egress Envoy listener adds a x-envoy-expected-rq-timeout-ms header, but this does not affect the ingress Envoy listener's behavior.
I have a test setup in which I have a very slow target upstream server running on port 9000, and I have the first (ingress) Envoy listener proxy port 30002 to port 9000 (the slow target server) and the second (egress) Envoy listener proxy port 30003 to port 30002 (the first Envoy listener). The whole config YAML file is below.
If I send a request to the first (ingress) Envoy listener proxy, the request succeeds:
curl localhost:30002 --header 'x-envoy-upstream-rq-timeout-ms: 20000'
But if I send a request to the second (egress) Envoy listener proxy, the request times out:
curl localhost:30003 --header 'x-envoy-upstream-rq-timeout-ms: 20000'
Is there a way to get header-based request timeouts to work in a service mesh configuration?
Regards,
Yifan
---
admin:
access_log_path: /mnt/logs/envoy/access_admin.log
address:
socket_address:
address: 0.0.0.0
port_value: 30001
static_resources:
listeners:
- address:
socket_address:
address: 0.0.0.0
port_value: 30002
filter_chains:
- filters:
- name: envoy.http_connection_manager
config:
use_remote_address: true
codec_type: auto
stat_prefix: ingress_http
route_config:
name: target_slow
virtual_hosts:
- name: target_slow
domains:
- "*"
routes:
- match:
prefix: "/"
route:
cluster: target_slow
http_filters:
- name: envoy.router
config: {}
- address:
socket_address:
address: 0.0.0.0
port_value: 30003
filter_chains:
- filters:
- name: envoy.http_connection_manager
config:
use_remote_address: true
codec_type: auto
stat_prefix: ingress_http
route_config:
name: envoy_chain
virtual_hosts:
- name: envoy_chain
domains:
- "*"
routes:
- match:
prefix: "/"
route:
cluster: envoy_chain
http_filters:
- name: envoy.router
config: {}
clusters:
- name: target_slow
connect_timeout: 1s
type: STATIC
lb_policy: ROUND_ROBIN
hosts:
- socket_address:
address: 127.0.0.1
port_value: 9001
- name: envoy_chain
connect_timeout: 1s
type: STATIC
lb_policy: ROUND_ROBIN
hosts:
- socket_address:
address: 127.0.0.1
port_value: 30002