samvera / serverless-iiif

IIIF Image API 2.1 & 3.0 server in an AWS Serverless Application
https://samvera.github.io/serverless-iiif/
Apache License 2.0
69 stars 21 forks source link

Look into Lambda Streaming Response to replace 6MB workaround #109

Closed mbklein closed 11 months ago

mbklein commented 1 year ago

AWS Lambda now supports streaming-enabled functions, with a soft response payload size limit of 20MB, instead of the hard 6MB limit on buffered responses. This might be an opportunity to simplify our deployment by getting rid of the need for the cache bucket/CloudFront failover origin workaround for large responses.

codeclout commented 1 year ago

@mbklein - We have implemented the streaming response by creating a Readable stream from the result of resource.execute()

e.g.

const result = await resource.execute();
  streamResponse.setContentType(result.contentType);
  const r = Readable.from(result.body);

  await pipeline(r, streamResponse);

We have confirmed it works as expected. Would you be interested in a pull request with the entire implementation?

mbklein commented 1 year ago

Sure!

codeclout commented 1 year ago

@mbklein - quick update

The PR was written on GFE, so therefore I need some approvals and I am working internally to retain the necessary approvals.