Expected Outcome
The service router request timeout will override the default timeout, allowing the default 15 seconds to be modified.
Prerequisites
- proxy default file
- service router file
Use Case
The service router provides the request timeout parameter to configure the timeout in Envoy sidecars. By default the timeout is 15 seconds, but with the following steps, this can be decreased or increased allowing upstream requests to be prolonged or shortened.
Procedure
-
In either yaml, hcl, or json, create the Service router config. Take note the unit of time is in milliseconds.
#hcl
Kind = "service-router"
Name = "virtual-service"
Routes = [
{
Match {
HTTP {
PathPrefix = "/test"
}
}
Destination {
Service = "counting"
NumRetries = 4
RetryOnConnectFailure = true
RetryOnStatusCodes = [403]
RequestTimeout = 20000 # 20 seconds
}
},
]
2. Create a proxy default configuration with the local_request_timeout_ms parameter set to zero. This disables the timeout for the local app in Envoy. Your service router will now override the local app request timeout now that it is disabled.
#hcl
Kind = "proxy-defaults"
Name = "global"
Config {
local_request_timeout_ms = 0
}
- Alternatively, you can add the local_request_timeout_ms in the proxy config section when registering the upstream service like the following:
#hcl
service {
name = "counting"
id = "counting-1"
port = 9003
connect {
sidecar_service {
proxy {
config {
local_request_timeout_ms = 0
}
}
}
}
check {
id = "counting-check"
http = "http://localhost:9003/health"
method = "GET"
interval = "10s"
timeout = "1s"
}
}
Once applied, you can see the local app default timeout being overridden by the service router when looking at the Envoy logs:
Additional Information
-
If you're running into issues with the request timeout still defaulting to 15 seconds, you can check the Envoy logs to see if the decoded x-envoy-expected-rq-timeout-ms header shows 15000. The decoded header can be seen under "router decoding headers:" when Envoy logs are in debug mode. For accessing and debugging Envoy logs, please refer to this article. The default timeout not being overridden means the local app request timeout is not disabled, and your proxy default or proxy configuration is possibly misconfigured.