What the API Connect invoke timeout actually does in DataPower
Draft!!
A transaction in your API Connect analytics takes 240 seconds to finish. You check the assembly invoke policy and timeout is set to 120 seconds.
The 120-second setting is not measuring what most people think it is.
What the invoke timeout actually measures
The timeout property on an API Connect invoke policy (default 60 seconds) is an idle timer waiting for the backend to start sending its HTTP response. It is not a stopwatch on the whole transaction.
In your API assembly definition in API Connect (what you see in the Assembly UI and OpenAPI YAML), the invoke policy is configured like this:
- invoke:
version: 2.3.0
title: invoke
target-url: http://backend.example.com/api/v1/orders
timeout: 60
verb: keep
backend-type: detect
chunked-uploads: true
persistent-connection: true
follow-redirects: false
inject-proxy-headers: false
inject-user-agent: true
stop-on-error:
- ConnectionError
DataPower compiles this policy into a native assembly-invoke object where timeout maps to the backend socket response timer and stop-on-error catches ConnectionError.
When DataPower executes an invoke policy:
- It opens a TCP connection (or reuses a persistent one from the pool) to the backend.
- It sends the request payload.
- It starts the
timeoutclock, waiting for the backend to send the HTTP response headers.
If the backend does not respond with any HTTP data within the configured timeout window, DataPower terminates the connection, triggers a ConnectionError, and diverts the transaction to your assembly error catch rule (returning an HTTP 500 by default).
If the backend sends the HTTP response status line and headers at second 118, the timeout condition is satisfied. The timer stops ticking for response headers.
The trickle problem: why slow payloads bypass the timeout
For the invoke timeout to trigger, there must be zero trickle.
How DataPower handles the connection:
- TCP Keep-Alive will not prevent a timeout. TCP keep-alives operate at layer 4 (empty ACK probes). They maintain the TCP connection in the network stack, but they do not satisfy DataPower’s application-level read timer. If a backend sends TCP keep-alives while stalling on the HTTP response, the invoke timeout still triggers and fires an HTTP 500 error path.
- HTTP keep-alive does not trickle. HTTP keep-alive (
Connection: keep-alive) is socket persistence between requests. During an active request, the connection is either waiting for bytes or receiving bytes. - Payload trickling resets the clock. If the backend sends HTTP headers and then trickles payload bytes across the wire — for example, using
Transfer-Encoding: chunkedand sending a few bytes every ten seconds — DataPower is actively reading application data. Because bytes are arriving, the socket is never considered idle.
A backend can take four minutes to deliver a 50 KB payload without ever triggering a 120-second invoke timeout, as long as no individual gap between arriving chunks exceeds the inactivity timer.
Persistent connections and connection pooling
By default, persistent-connection is enabled (on) on every assembly-invoke action.
Persistent connections allow DataPower to keep backend TCP sockets open in a connection pool for reuse across successive API calls, avoiding the handshake overhead of TCP and TLS on every transaction.
Managing persistent connections involves three distinct constraints:
- Inactivity time — how long an idle pooled connection stays open before DataPower closes it.
- Usage time (lifetime) — the maximum duration a single socket connection may exist.
- Usage count — the maximum number of requests sent over a single socket before retiring it.
Most backend HTTP servers enforce their own keep-alive timeouts and maximum request counts. On the gateway side, persistent-connection on means DataPower maintains that socket pool until the server closes it or the idle timeout expires.
Persistence over localhost and port exhaustion
There is an old DataPower guideline that recommended disabling persistence for loopback connections (127.0.0.1 or localhost). That advice stemmed from an edge-case race condition where both sides close the socket simultaneously, producing an occasional failure rate of roughly one in a million transactions.
If your application can tolerate (or retry) a one-in-a-million race failure, feel free to use persistence over localhost.
Disabling persistence on localhost has its own trade-off: under high request volume, creating a new TCP connection for every request can lead to ephemeral port exhaustion on the loopback interface as sockets accumulate in TIME_WAIT.
How slow backends cause gateway memory pressure
Teams often configure a 120-second timeout thinking: “If a backend is struggling, the gateway will cut it off after 2 minutes to protect itself.”
That assumption does not match how the gateway works.
Under load:
- 1,000 clients make API calls per minute.
- A downstream backend slows down, taking 180 seconds to trickle each response back.
- Because data is trickling in, none of the 120-second invoke timeouts trigger.
- Instead of failing fast, all 1,000 transactions remain active in DataPower memory simultaneously.
Each in-flight transaction holds socket descriptors, assembly context variables, and streaming buffers in memory. As concurrent connections pile up, DataPower enters memory pressure, triggers watchdog throttling, and can restart due to memory exhaustion.
The slow backend was not cut off; instead, transactions stayed open on the gateway until resources ran out.
How to protect the gateway
Three things you can do on the gateway:
1. Reduce invoke timeouts to fail fast
Set the invoke timeout to match your actual service-level expectation. If a backend normally responds in 200ms and should never take more than 5 seconds, do not leave the timeout at 60s or 120s. Set it to 5 seconds. Failing fast with an error protects the gateway and informs the client immediately.
2. Set frontside client timeouts
Align your client-facing timeouts with your backend SLAs. If your ingress controller or load balancer cuts connections at 60 seconds, an invoke timeout of 120 seconds on DataPower means the gateway continues processing after the client has disconnected.
3. Use gateway extensions for backend pooling limits
If you need hard caps on backend persistent connection lifetimes, connection limits, or socket idle timers beyond what the API Connect assembly UI exposes, configure backend connection properties or User Agent settings via a gateway extension (gwd_extension). IBM has a full configuration example and walkthrough in Creating a gateway extension to tune timeout settings for API Gateway.
Limitations and Notes
- The invoke
timeoutproperty only controls the wait time for the backend response on that specific invoke action. It is not an end-to-end API transaction timer. - Multiple sequential invoke policies in a single assembly have independent timeout timers. Three invokes with 60-second timeouts can result in a 180-second total execution time.
- If an API assembly performs heavy schema validation, XSLT, or GatewayScript processing after receiving the backend response, that local compute time is not bounded by the invoke timeout.
Summary
The invoke timeout is an idle timer for the start of a response. It will not protect the gateway if a backend starts replying and trickles data slowly. Keep invoke timeouts aligned to your actual backend SLA so slow calls fail fast, and do not rely on the invoke policy to act as an overall transaction stopwatch.
Next: Stopping slow backends from causing DataPower memory pressure (Part 2) — the timeout hierarchy, gateway extension tuning, and why raising timeouts makes the problem worse.
