Queenvictoria
Queenvictoria

Reputation: 401

502 error when Serverless image handler requests a large file size

I've deployed the AWS Cloud formation Serverless image handler to resize images in an S3 bucket which is working well. It is using Cloudfront, API Gateway, Lamdba, and a custom domain.

My original images (PNGs) are of a reasonable size (~5MB or ~5000px across) and my derivatives are of various sizes. Up until about fit-in/2048x2048 everything works well. Above that though I get a 502 "Internal server error".

I've tried maxing out memory and timeouts to no avail. Does anyone have any idea what's going on there? Is there some invisible limit?

{
    "message": "Internal server error"
}

Upvotes: 0

Views: 1995

Answers (2)

Leon Braun
Leon Braun

Reputation: 415

This issue is caused by the payload limit of 6mb for Lambda Functions. As a workaround it is possible to save the images directly to a output bucket and deliver them from this bucket to the customer.

The issue is in the future backlog since 07/2018 (see here or here)

Upvotes: 2

Kannaiyan
Kannaiyan

Reputation: 13035

The architecture may need a correction here. Whenever you deliver large files, you need to leave the responsibility to S3 / CloudFront. Lambda should take care of authenticating / authorization of the content.

API Gateway has a limitation on the lambda response limit.

https://docs.aws.amazon.com/apigateway/latest/developerguide/limits.html

Upvotes: 0

Related Questions