When a cloud-native gateway forwards requests to backend services, slow or unresponsive backends can hold connections open indefinitely, exhausting gateway resources and degrading the experience for other clients. A timeout policy sets the maximum time the gateway waits for a backend response on a specific route. If the backend does not respond within this period, the gateway returns HTTP 504 (Gateway Timeout) to the client.
Timeout policies are configured per route. Set shorter timeouts for latency-sensitive APIs and longer timeouts for batch-processing or heavy-computation endpoints.
How it works
When you enable a timeout policy on a route, the gateway starts a timer after it forwards the request to the backend service.
If the backend does not return a response within the configured timeout period, the gateway returns HTTP 504 (Gateway Timeout) to the client.
The following table summarizes the behavior for different timeout values:
| Timeout value | Gateway behavior |
|---|---|
Greater than 0 | Waits up to the specified number of seconds for a backend response. Returns 504 if the backend does not respond in time. |
0 or policy disabled | Waits indefinitely. Use only for streaming APIs or long-running operations. |
Setting the timeout period to 0 has the same effect as disabling the policy. For most request-response APIs, set an explicit timeout to prevent resource exhaustion.Prerequisites
Before you begin, make sure that you have:
A cloud-native gateway instance in Microservices Engine (MSE)
At least one route configured on the gateway
Set up a timeout policy
-
Log on to the MSE console. In the top navigation bar, select a region.
-
In the left-side navigation pane, choose Cloud-native Gateway > Gateways. On the Gateways page, click the ID of the gateway.
-
In the left-side navigation pane, click Routes. Then, click the Routes tab.
Find the route to modify, and click Policies in the Actions column.
Click the Timeout tab.
Configure the following parameters, then click Save.
Parameter Description Timeout Period Maximum time the gateway waits for a backend response, in seconds. A value of 0means the gateway waits indefinitely.Enable Toggle the policy on or off. When the switch is on, the timeout policy takes effect. When the switch is off, the gateway waits indefinitely, as if no timeout is set.
Verify the timeout policy
After you enable the timeout policy, send a test request to the route and confirm that:
Requests that complete within the timeout period return the expected response.
Requests that exceed the timeout period return HTTP
504 (Gateway Timeout).
Production guidance
When you deploy timeout policies in a production environment, consider the following:
Measure actual response times first. Before setting a timeout, collect baseline latency metrics (p50, p95, p99) for the backend service. Set the timeout above the p99 latency to avoid unnecessary
504errors under normal load.Avoid disabling timeouts on request-response routes. Setting the timeout to
0or disabling the policy causes the gateway to wait indefinitely. Reserve this for routes that serve streaming responses or long-running operations (such as file uploads or report generation).