As someone who uses Lambda heavily I find this post somewhat disappointing from a "best practices" standpoint. No mention of Lambda best practices like: - Using CloudFormation - IAM policies - Managing config - How to handle databases and connection pools Instead we get a logging suggestion that while interesting (I too prefer ElasticSearch to CloudWatch logs) is definitely not Lambda best practice. And suggestion ab…
I actually use Lambda too but I never thought using CloudFormation instead of Ansible. Last time I checked CloudFormation was really difficult to deal with. Might have changed since.
AWS Lambda – Best practices
31–40 of 68 posts
Re: AWS Lambda – Best practices
#32Earlier quoted context omitted.
How do you use database connection pools with lambda? I thought it wasn't possible.
AWS will sometimes reuse the container in which your Lambda runs, so if you set up e.g., database pools during load time, they're often still there the next time. Related: https://aws.amazon.com/blogs/compute/container-reuse-in-lamb...
Re: AWS Lambda – Best practices
#33Re: AWS Lambda – Best practices
#34The value is that it does deploy, the route-mapping, config management, and also allows you to 'keep-warm' if you want to keep the backend responsive even after zero/low traffic.
My hope is that best practices are going to continue being distilled into these deployment/wrapper frameworks.
Re: AWS Lambda – Best practices
#35A while ago (pre proxy), it was nearly impossible to send back 302 redirects cleanly.
With LAMBDA_PROXY, it's not clear that you can actually return binary data through the Api Gateway. There's the undocumented isBase64Encoded parameter, but as far as I can tell, it's ignored. It doesn't trigger an error, but it doesn't decode base64 either.
Just this week I'm working on moving a static html site + a couple of dynamic urls over. I can work around the binary issue, but serving images is a solved problem in the rest of the world.
Re: AWS Lambda – Best practices
#36Earlier quoted context omitted.
AWS will sometimes reuse the container in which your Lambda runs, so if you set up e.g., database pools during load time, they're often still there the next time. Related: https://aws.amazon.com/blogs/compute/container-reuse-in-lamb...
Right, but only one request can be in progress against a container at a time, correct? So there's no reason for your pool to allow more than one connection. Of course, that might still be useful for retry, etc. if the connection went away while the container was frozen.
Re: AWS Lambda – Best practices
#37Every time I look at Lambda+API Gateway for a web api, there's always been one little thing that makes things way harder than they should be. A while ago (pre proxy), it was nearly impossible to send back 302 redirects cleanly. With LAMBDA_PROXY, it's not clear that you can actually return binary data through the Api Gateway. There's the undocumented isBase64Encoded parameter, but as far as I can tell, it's ignored.…
- When dealing with uploads have an API call to get a pre-signed S3 upload URL
- When dealing with downloads using HATEOAS and/or the Location header to send the client to S3 to grab the actual file.
It requires some client-side designing around eventual consistency but it works well and is very scalable.
Re: AWS Lambda – Best practices
#38Earlier quoted context omitted.
I've been using Lambda since the beginning (was an early private beta user). I am actually considering writing a book or perhaps some courseware. I don't blog. Unfortunately, if I do I cannot post it here as it would defeat the purpose of using a throw-away account :(
I am publishing a book in the following months that covers all the items you mention, IAM, fully Cloudformation, deployment with Gradle etc. The language I picked is Java because we thought with the publisher that Java at Lambda has very little written resources. If you are interested here is the link and if you pre-order it you can access to finished chapters already: https://www.amazon.co.uk/Building-Serverless-Arc…
Re: AWS Lambda – Best practices
#39> My opinion, when going serverless, I wouldn’t think of using RDBMS’s (although you can) and instead use databases like Elasticsearch, DynamoDB, Mongo etc. This is a vague statement that's not really based on evidence, and I'm not sure why using Postgres, for example, is going to be so much worse for most use cases than these NoSQL solutions.
As I explain over here ( https://news.ycombinator.com/item?id=13774041 ), trying to use Lambdas with your existing servers, like Postgres, can cause some serious complications.
Side note, is that just startup time for a single lambda `node`? Won't you be running >>1 node and not really care about startup time for any single node?
Re: AWS Lambda – Best practices
#40Earlier quoted context omitted.
How do you use database connection pools with lambda? I thought it wasn't possible.
AWS will sometimes reuse the container in which your Lambda runs, so if you set up e.g., database pools during load time, they're often still there the next time. Related: https://aws.amazon.com/blogs/compute/container-reuse-in-lamb...