aws-samples / image-optimization

Simple, performant and cost efficient solution for optimizing images using Amazon CloudFront, Amazon S3 and AWS Lambda
MIT No Attribution
173 stars 106 forks source link

Handle large images gracefully #1

Closed vassbence closed 6 months ago

vassbence commented 1 year ago

Hi!

First eval thanks for this great repository :)

I've noticed a small thing that might not have been accounted for, the 6MB Lambda response limit. If a large image is requested and optimized it still might be larger than 6MB and thus Lambda will throw an error and nothing will be served to the user.

To fix this my initial idea was to add the original bucket as the second fallback to the CloudFront Distribution, this way if an image is not yet optimized and cannot be optimized by Lambda it can still be served from the original S3 bucket as is. But it seems like a single origin group only allows 2 members in it.. So maybe the Lambda could send a 307 redirect to the original bucket?

achrafsouk commented 1 year ago

Hello, thanks for raising this.

There are some options:

achrafsouk commented 1 year ago

I will consider adding the second option to this solution natively

purdy commented 9 months ago

Do you have any updated code for how the second solution would work?

achrafsouk commented 9 months ago

ok I did a change, can you try the changed solution in this branch? https://github.com/aws-samples/image-optimization/tree/graceful-failover

achrafsouk commented 6 months ago

merged into main