AWS fundamentals: What is Lambda?
In this blog post series we’ll take a closer look at Amazon web services (AWS) and all their Serverless related services in detail.
Today we look at Lambda. What is it and how does the Serverless framework use it?
This chapter is a free sample taken from our “Learn Serverless” book.
AWS describes Lambda as a “data processing service which runs code when it’s externally invoked (e.g. through events or other triggers)”.
This sounds abstract and hard to understand but believe me. It’s not that hard.
It simply means that you can zip and upload your code to AWS and Amazon sets up everything for you so that the code can be run.
Lambda was celebrated as a game changer in cloud computing when it was introduced at re:invent in 2014. And you’ll see why in the next parts.
The beauty of it is that you don’t have to manage any servers or infrastructure to ensure your code runs smoothly. Amazon takes care of everything. This also means that you don’t have to think about security updates for your OS, scalability, availability or everything else.
It doesn’t matter if you have 2 users or 1 million who hit your function. No slow responses or downtime due to overwhelming customer engagement.
Another bonus is that you only pay for the time your function runs. This reduces the costs of your application to a fraction of what you’ve paid before.
They analyzed one production ready app (16000 requests / day @ 200ms avg. response time) and calculated how much it would cost when hosting it with EC2 in contrast to lambda.
The results are astonishing:
Two EC2 instances $2.97 / day
Lambda $0.05 / day
This is huge! Imagine how much money big companies can save when switching to a serverless implementation.
Lambda supports different runtimes as well.
As of the writing of this blog post Node.js, Python and Java are supported.
This means that you can develop different parts of your application with different programming languages.
How Serverless uses Lambda
Lambda is a core functionality you’ll use (nearly every time) when developing applications.
You’ll write the core components of your application in a runtime language of your choice and Serverless takes care to minimize, optimize, zip and upload your code to AWS so you don’t have to take care of the manual process you have to run through when doing this through the AWS web console.