AWS Made Simple: WTF is AWS Lambda?
January 19, 2020
Before we start
If you don't feel like reading and prefer to watch a bunch of quick (less than 3 minutes) videos - this blog series is based on a 💰free 💰egghead.io video collection I've published recently, check it out here: Learn AWS Lambda from scratch.
WTF is AWS Lambda?
When someone says that:
Yeah, we're going serverless with AWS
They probably mean AWS Lambda
AWS Lambda is an Amazon Web Services service which operates in a Function as a Service (FaaS for short) model. What that means is that you, as a developer, are only responsible to provide the function (that is - the code) that needs to be executed once the lambda function runs. Everything else (servers, infrastructure, scaling) is taken care of by AWS.
This is what serverless means.
Of course, there ARE servers, but you, as a developer, you don't have to care about provisioning and maintaining servers. Which means that you get to focus on implementing your business logic and solving your problems, instead of having to tinker with servers and worry whether they'll survive the next wave of customers.
Okay, but this sounds expensive
It's not! With AWS Lambda you only pay for the compute time you consume.
What that means is that a lambda function can take up to 15 minutes to execute, but if your function takes only a second to run you will only pay for this one single second of execution time.
The best part is - you don't start paying right away.
AWS Lambda free tier usage includes ONE FREAKING MILLION free requests per month.
In other words - you only start paying one your service gets rather popular, one million request per month is pretty significant.
Once you go above a million requests per month, you pay only \$0.20 per million requests. (An exercise for the reader: calculate how many requests you'd need to handle before the cost of your serverless functions becomes more than a cup of coffee from Starbucks).
What can I use to create my lambda functions?
There are a number of programming languages supported in AWS Lambda:
.NET, Go, Java, Node.js, Python, Ruby - a little something for everyone (no jQuery though).
How do I trigger a lambda function?
A lambda function can be triggered by quite a lot of sources.
- AWS Gateway can trigger your lambda function by an HTTP request (useful when you want to create an API
- AWS IoT - you can literally have a "push to prod" button on your desk
- AWS S3 - a lambda function can be triggered by uploading a file to an S3 bucket (if you don't know what a bucket is, check this post out.)
- AWS DynamoDB - you can trigger a lambda function by for instance adding an item to your DynamoDB table
It's a ridiculously powerful paradigm, allowing you to compose major workflows and business logic out of serverless functions, while keeping your costs extremely low.