aws-samples/image-optimization

Handle large images gracefully

Closed this issue · 5 comments

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?

Hello, thanks for raising this.

There are some options:

I will consider adding the second option to this solution natively

purdy commented

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

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

merged into main