iAviator
iAviator

Reputation: 1447

API Gateway stream large size content in response

Is there any way I can stream content in API response which is backed by AWS API gateway. My content can be very large size and i want to stream it to the requestor. At present i see there is a limit of 10Mb payload size on API Gateway.

I also generate the data at runtime when i get the request on my EC2 machine and as soon as some data is generated i want to start streaming it to the requestor.

Is it possible? How?

Upvotes: 3

Views: 6564

Answers (1)

thomasmichaelwallace
thomasmichaelwallace

Reputation: 8484

As you've seen, API Gateway has hard limits response sizes. This is because it's designed for quick and transactional use-cases. (API Gateway will also not keep a connection open longer than 30 seconds, so if you're streaming a file that takes longer than this to download, you'd be in trouble too.)

For these cases you might consider a different pattern, like:

  • Have your EC2 machine upload the result to S3 and have API Gateway return a pre-signed url to download the response from S3. This would stream the download, but would have to wait for the EC2 -> S3 upload to complete first.
  • Use Elastic Beanstalk, that way you would be in control of the server and able to keep your connections open for as long as you wanted, and send as much data as you want.

Upvotes: 3

Related Questions