by philliphaydon · 6y ago · 0 comments
Lambdas have a 6mb response size. Api gateway has a 10mb response size. If you go ALB to Lambda. And your response is over 1mb. Your response will fail. Because the ALB team decided to introduce a random 1mb limit, not document it as a limitation, and added it to their trouble shooting notes instead.
So if you need to return a small PDF or something from a lambda via ALB. Good luck.
The reason they do this is to keep the alb running efficiently by not having to architect for random large responses.
API Gateway: 10mb
Lambda: 6mb
ALB: 1mb
Yet if your target is an ec2 instance, there's no limit on the load balancer. So IMO the limit for a lambda target should be the limit imposed by Lambda itself. 6mb.
ALB to containers or servers is a different beast - here the entire request and response need not be buffered at all (there might still be a very small buffer, mostly negligible), so streaming responses, websockets etc become possible.
We use lambda to resize images, so we do push against these limits a bit, but it's a fair tradeoff for the advantages - no worries about CPU throttling from too many requests, no waiting for servers to start for spiky loads etc.
https://docs.aws.amazon.com/elasticloadbalancing/latest/appl...
Right at the top of the page, underneath the header "Limits"
> The maximum size of the response JSON that the Lambda function can send is 1 MB.
https://docs.aws.amazon.com/elasticloadbalancing/latest/appl...
Which I complained about because it wasn't mentioned as lambda as a target docs. I guess they amended it.