DEV Community

ozersubasi
ozersubasi

Posted on

What is AWS Lambda?

Hello, in this article I wanted to talk about what is AWS Lambda and why we should use it;

AWS Lambda is a serverless computing service to run written code without the need to provision and manage servers.
Thanks to AWS Lambda, our code runs only when needed and is charged according to the processing time, there is no charge when the code is not running.

The need can vary from a few requests per day to thousands of requests per second, in which case AWS Lambda automatically scales to prevent any loss in performance.

AWS Lambda, runs the written code on a highly available infrastructure and performs all the operations such as capacity and automatic scaling, system maintenance and logging. We just need to write our code in one of the languages that AWS Lambda supports.

Why we should use AWS Lambda?

AWS Lambda is an ideal service for many standart scenarios. We need to create an infrastructure before starting application development. Hosting a server, performing the necessary installations, coding and running the application; these are mean seperate workloads. Wouldn't be nice to do only code and run the application without dealing with all these? Well, that's the best part of working serverless! We write the code, upload as a ZIP or container image and application is ready to go! Now all we need is trigger this Lambda function. Function will run only whenever triggered and will not charge when it is not running!

image

Of course, it may be easy to do these steps now, there may be questions in mind such as what is what makes AWS Lambda attractive? But wait! we just ran the application!
In the free version of AWS Lambda, the first 1 million request per month are free, then it is calculated according to milliseconds and the number of times the code is triggered and the cost will only $0.20 per 1 million request.

In other words, the cost of implementing an idea quickly and testing whether it will work is almost zero!

In addition, there is a discount up to %17 with plans such as the Compute Savings Plan on the services you will use on production.

Scalability is the most important thing that makes AWS Lambda attractive. There is no matter how many instant request your application getting, even if there are hundreds of thousands of instant request, AWS Lambda scales through the need and you don't need to worry about inaccessibility and continue without any problems. The good side of that is no need to spend lots of money for the server and don't need to consider the risk of inaccessibility if the application suddenly get thousands of instant requests or more.

The run time of the code can be also optimized by select appropriate memory size for the function to be executed. In this way, function will perform consistently at the appropriate scale. The following workflow example demonstrates the operation steps of weather application;

image

User, clicks the link to find out the weather conditions in their area.
Amazon API Gateway makes API call to the related endpoint. Lambda is triggered here.
Lambda function gets weather condition information of the region requested by the user from DynamoDB and returns to the user.
Besides, there are many scenarios where AWS Lambda used on AWS.Here you can see the Todo application source code folders as an example. AWS Cognito used as the user authentication method, and you can see that each required function for Todo App is foldered separately in the below image.

image

Source:

https://aws.amazon.com/tr/lambda/

Top comments (0)