Lambda Deep Dive (Complete)
parts 1-5 combined here, for one incredibly autistic look into AWS Lambda
Hello anons, avatars, cartoons, and the real ones among us. Celt here today to talk about AWS Lambda. Lambda is a very interesting service in that it provides ‘serverless’ compute. AWS has abstracted everything from the customer, except the application code, permissions, and some configurations. This greatly increases time to market for the customer, as all they really need to do is write the code, and attach the correct permissions. Yes many people do not like the term serverless but lets just move on. This post is going to be broken down into parts, to keep things digestible and actionable.
REQUIRED READING
AWS Lambda Deep Dive Chapter 1
When we say serverless compute, essentially you are consuming the execution of code on an environment that AWS manages. AWS managing the infrastructure provides many benefits, which are going to be expanded on in the Selling Points section. Lambda is very common service that almost every production account utilizes in some way.
Selling Points
serverless - the customer does not need to manage any servers. This includes tasks such as creating a highly available and fault tolerant environment, patching, maintenance, logging, and monitoring.
Speed to market - with AWS managing the infrastructure your development teams can focus significantly more on application code and business logic resulting in significantly faster speed to market, which drives innovation on your business products. Ultimately resulting in better products.
Scalability and Elasticity - being a serverless offering, Lambda can scale up with virtually no limit with parallel executions (note there is an upper limit on memory), and can scale down to 0. Most of this is done with little intervention from the customer.
Cost - The customer pays for what they actually use, billed per millisecond of execution time. You don’t pay for idle time when your Lambda function is not being used. This can be a huge saver for certain workloads where always-on is not a requirement.
Workloads and Use Cases
Similar to general serverless, Lambda is optimal for workloads that have idle time, have execution times lessthan 15 minutes, or do not high performance computing requirements. That makes sense because if that is true then just run the service on dedicated compute like EC2 or even something like ECS.
The first common use case for Lambda is automation jobs. Something like this could be like getting an S3 object from another account or sending out an email when a certain event is observed in Eventbridge. This is a good use case as the automation jobs are mostly idle, so you take advantage of the cost structure of Lambda as opposed to a dedicated virtual server.
A second common use case would be data analytics. You could have a DynamoDB table and stream that publishes items (customizable) and Lambda can do things like generate custom metrics, or execute other things like sending an email to a user if a certain thing is in the payload for the item.
A third common use case would be a website. It is common to see a website backend on Lambda fronted by an API Gateway, this gives you the serverless stack. Lambda would take care of the dynamic content. The result is a highly scalable website with no servers to manage.
Pricing
Lambda is pay-as-you-go and the cost is derived from number of executions and execution time (milliseconds). The amount of memory is the driver for execution time, as each size increment has a cost. See below
For example, that is the price for x86, note that Arm would have different price and is generally cheaper. With Lambda you are getting billed for what you *actually* consume, vs purchasing dedicated compute like EC2 you are being billed hourly no matter the actual level of resource consumption.
Lambda has a generous free tier at 1 million perpetually free requests per month, which is up to 3.2 million seconds of compute time. This alone is enough for people to run small
projects on Lambda for free, forever.
Keep reading with a 7-day free trial
Subscribe to Software Architecture with BowTiedCelt to keep reading this post and get 7 days of free access to the full post archives.