Hi,
I am using Tyk v.5.9.1 open source version in k8s.
I would like to ask if Tyk can stream data to a specific endpoint.
The data flow would be:
client --> 4GB data (request json body) -> Tyk -> web service endpoint /stream
The web service can handle the 4GB streaming data. Can Tyk also manage this?
What would be the best method to use with the OAS?
Thanks
Hi Pascal,
Your goal is to get a ~4 GB JSON payload from your client through Tyk 5.9.1 (OSS, Kubernetes) to /stream, without Tyk rejecting it, timing out, or holding it all in memory. Is that right?
The TL;DR is that this is a commonly requested feature as detailed in this issue, and we are looking to optimize transfer of large files but that is not yet done. While it is technically possible, there are a number of caveats. Here’s why:
First, by default, Tyk’s reverse proxy handler creates a copy of standard HTTP request bodies in memory. With the default setup, it would risk OOM kill on the gateway. For instance, testing this with version 5.9.1 and confirmed the gateway tries to hold 4 GB in a default 512Mi pod, and the pod is OOMKilled.
Second, is there will be middleware buffering: If any payload-inspecting middleware is active on the API (such as JSON schema validation, body transformations, URL rewrite payload inspection, caching, or detailed analytics recording), the payload is read into memory again.
Here are the workarounds if routing the 4GB payload through Tyk is mandatory:
- Allocate significant memory to the Tyk pod/node in Kubernetes, ideally double the size of the payload. In addition, do consider memory allocation if multiple concurrent calls are run, as each would consume large amounts of memory. This would require you to test on your end if say 8-12GB would suffice.
- Ensure all body-processing middleware are disabled for this endpoint in your OAS definition (no transforms, validations, plugins, or caching).
- Disable detailed analytics if this is enabled as well.
- Increase
http_server_options.read_timeout, http_server_options.write_timeout, and proxy_default_timeout to accommodate transfer durations. More on the timeouts here.
Generally, the largest limitation would be memory allocation.