Document updated on Sep 27, 2018
Being KrakenD an API Gateway that talks to other services, being able to control the waiting times for different aspects is crucial. KrakenD will allow you to fine-tune these settings.
The timeouts can apply to:
Additionally, you can control the number of maximum IDLE connections.
The timeout
key in the krakend.json
at the root level is used in the first place to apply a default timeout for the whole duration of the pipe (and not only the connection to the backends). The timeout takes into account all the time involved between the request, the fetching of the data, manipulation and any other middleware. You can see it is an end-user timeout.
{
"version": 3,
"timeout": "2000ms"
}
Even the timeout
value in the root level sets a default timeout for all the endpoints, you can override it later on any specific endpoints.
To do so, just place it inside the desired endpoint:
{
"version": 3,
"timeout": "2000ms",
"endpoints": [
{
"endpoint": "/default-timeout"
},
{
"endpoint": "/different-timeout",
"timeout": "1s"
}
]
}
The example above will use 1 second timeout for the /different-timeout
endpoint and 2 seconds (expressed in milliseconds) for any the other endpoint. Note that the backend
section is omitted for better reading.
When the timeout for the whole pipe is reached, the request is canceled and the user receives an HTTP status code 500 Internal Server Error
.
The logs will show a line like:
Context deadline exceeded
In addition to the timeouts for the whole pipe, you can configure the specific HTTP transport timeouts and the HTTP server timeout.
For more information see:
All the settings in these sections work just like the pipeline timeouts. If you place the values in an endpoint, they will override the global setting.
The documentation is only a piece of the help you can get! Whether you are looking for Open Source or Enterprise support, see more support channels that can help you.
We use cookies to understand how you use our site and to improve your overall experience. By continuing to use our site, you accept our Privacy Policy. More information