5 ms·
One thing is that ALB to Lambda restrictions suck. Lambdas have a 6mb response size. Api gateway has a 10mb response size. If you go ALB to Lambda. And your re
by philliphaydon 7y ago
One thing is that ALB to Lambda restrictions suck.
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.
- jcims 7y agoSomebody has a war story
- james_s_tayler 7y agoWar stories are the best part of HN.
- internalthief 7y agoIt is documented, at least on this page: https://docs.aws.amazon.com/elasticloadbalancing/latest/application/lambda-functions.html 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.
- philliphaydon 7y agoAh this must be relatively new. The only documentation I could find or AWS Support Business Support / Lambda team could give me was a link to: https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-troubleshooting.html#target-http-errors 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.
- jk563 7y agogit blame suggests the change was made 15 months ago, though that doesn't take it to account time to publish. Which I guess just goes to show that it can be tough to find information on the docs, despite them been relatively decent as far as docs go (in my opinion).
- jedberg 7y agoFYI for anyone reading, the expected architecture is to return the URL to an S3 object that is your larger than 1mb response. The reason they do this is to keep the alb running efficiently by not having to architect for random large responses.
- philliphaydon 7y agoThe problem I have is, is the limit is less than the limit imposed by Lambda itself. Which is less than the limit imposed by API Gateway. 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.
- sudhirj 7y agoWhile I'm not disputing the limit numbers or whatever hardship they might cause, it's worth noting that this is a basic limitation of the original Lambda model and maybe FaaS in general. The capability comes from running a giant pseudo-infinite mesh of isolated execution environments that load your code and execute on demand, while having to buffer both the request and response to make sure clients are protected from the details. This buffering means that size of the buffer will always be limited - the team managing might make the buffers bigger based on experience, but it's not a solved problem. 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.
- inopinatus 7y agoLambda was not designed for request/response. It’s an event driven service. Wrapping API gateway around it is an architectural blunder, and leads to folks like the GP wondering why their use case is a shitty fit.
- fulafel 7y agoThat's pretty damning, lots of innocent REST messages can be more than 1MB. Can you have larger bodies in chunked encoding?