Start with the exact failure
Record the request time, route, caller, environment, correlation ID, and the timeout reported by the client. Determine whether the connection could not be established, the response headers never arrived, or the response body stalled. These point to different parts of the path.
Compare a failing request with a successful one using the same route and payload size. Check whether the issue affects every caller, one region, one dependency, or only peak traffic. Do not include access tokens, secrets, or sensitive payloads in diagnostic logs.
Trace each hop
- Caller: Check DNS, TLS, connection-pool exhaustion, client timeout settings, and whether the client cancelled the request.
- Gateway or proxy: Compare its request duration and upstream duration. Check route policies, rate limits, connection limits, and the configured upstream timeout.
- API service: Use the correlation ID to inspect queueing, CPU or memory pressure, database calls, and downstream dependency latency.
- Dependency: Check whether a slow database, identity provider, or remote API dominates the end-to-end time.
Propagate one correlation ID across the request path and compare timestamps from each component. If the gateway reports a short upstream duration but the caller still times out, investigate the client-to-gateway connection and response transfer separately.
Set a timeout budget
Choose a caller deadline that reflects the user or workflow need, then allocate smaller limits to the gateway and downstream calls so the service can return a controlled error before the caller gives up. Leave time for error handling. Raising every timeout can tie up connections and threads longer without fixing a slow dependency or traffic bottleneck.
Example client-side deadline (use the equivalent supported by your runtime):
const response = await fetch(url, {
signal: AbortSignal.timeout(2000),
});
This limits how long the client waits; it does not prove the server stopped processing.
Retry only safe operations
A timeout does not prove that the server did no work: it may have committed a change before the response was lost. Retry reads and explicitly idempotent operations with a bounded policy, exponential backoff, and jitter. For a non-idempotent write, use an idempotency key or reconcile the operation's result before trying again.
See the retry and duplicate-event guide for consumer-side deduplication. For choosing between an immediate API call and asynchronous work, read the request-response pattern notes.
Verify the fix
- Compare latency percentiles and timeout rate before and after the change.
- Test under representative concurrency and payload sizes.
- Confirm that a dependency outage returns a bounded, actionable error.
- Verify that retrying a timed-out write cannot create a duplicate business effect.