AWS Lambda - An Introduction

AWS Lambda - An Introduction

What is AWS Lambda?

First of all, we need to understand what is serverless:

What is serverless?

Serverless is a new paradigm in which the developers don’t have to manage servers anymore; they just deploy code. Serverless doesn’t mean there are no servers, it means you just don’t manage/provision/see them.

It's a cloud-based development approach, in which developers are free to focus on only writing code instead of managing server issues. Serverless also supports auto-scaling which means that the computing storage and processing are allocated on demand.

Returning to the title, lambdas are basically virtual functions. AWS Lambda is a role-based cloud service that eliminates the provisioning and maintenance needs of complex infrastructure. With Lambda, we don't need to worry about scaling our infrastructure and removing unnecessary resources, since all of this is handled in parallel.

Summarizing…

  • Virtual functions?
  • Limited by time
  • No servers
  • Run on-demand
  • Scaling automatically.
  • Function as a service
  • All you need to do is to write the code

What are the benefits/advantages of using AWS Lambda?

  • It’s a highly flexible tool to use
  • Easy pricing: pay per request and compute time (pay per calls and pay per duration)?
  • Free tier (first 1M requests are free and 400mil GBs of compute time)
  • Event-driven: get invoked when needed
  • Easy to get more resources per function (Up to 10GB of RAM is the limit)
  • Increasing RAM will also improve CPU and network
  • It’s serverless architecture, you don’t need to worry about managing or provisioning servers
  • Due to serverless, time and effort saved by creating and maintaining the necessary infrastructure
  • Allows us to run our Lambda function simultaneously with other Lambda functions; that is, we will not have to worry about stuck queues
  • We can provision and run multiple instances of the same Lambda function at the same time
  • Helps you to execute the code only when needed
  • Lambda functions are stateless so that they can be scaled quickly.
  • Supports a lot of programming languages, Docker

What are the supported languages?

Natively supports:

  • Node.js (JavaScript)
  • Python
  • Java (Java 8 and 11 compatible)
  • C# (.NET Core)
  • Powershell
  • Golang
  • Ruby

Also, it provides a Runtime API that allows you to use any additional programming languages to author your functions.

Common uses cases:

There are a lot of uses cases using AWS Lambdas, these are some examples:

  • Build scalable API
  • Real-time data processing
  • Automate backups
  • Analyze real-time logs
  • Build apps sensitive to latency
  • Convert documents into different formats in real-time
  • Use in Amazon products like Alexa
  • Develop scalable backends for mobile apps, web apps, etc

What are the disadvantages/limitations of AWS Lambda?

  • Functions will expire after 15 minutes (cannot use for long-running workloads)
  • The amount of available RAM varies from 128 MB to 3008 MB with an increment of 64 MB between each option
  • Lambda code must not exceed 250 MB and the compressed version must not exceed 50 MB
  • There is a limit of 1000 requests that can be executed simultaneously, any request above this limit will be throttled and you will need to wait for other functions to finish executing
  • Cold start time: when a function hasn’t been used for a while (~10min), the container where the Lambda is running will be cooled, and the function will be deactivated. When it’s invoked again, we might experience some latency due to environment settings. In the worst cases, your function can take up to 5 seconds to respond
  • You can’t install any additional software if this is a requirement of your application
  • Although the price is very convenient, its bills can increase quickly if you don’t know to optimize AWS costs, so you have to be aware of this and always monitor

Pricing

Basically, you pay for:

  • Number of requests
  • Execution time (duration)

Lambda executions are included in the Free Tier, and this is not like other services whose limit is 12 months. For AWS Lambda, the Free Tier is: the first 1M requests are free and 400mil GBs of compute time per month.?

The amount of money you pay will depend on the region, although most have the same costs. This is an example I got from https://aws.amazon.com/lambda/pricing/ for the region US East (N. Virginia):

No hay texto alternativo para esta imagen

Duration cost depends on the amount of memory you allocate to your function. You can allocate any amount of memory to your function between 128 MB and 10,240 MB, in 1 MB increments.

Also here is an example for the region US East (N. Virginia):

No hay texto alternativo para esta imagen

You can configure and calculate your costs at this link:?

https://calculator.aws/#/createCalculator/Lambda

Conclusion

Lambda is one of the most popular services in AWS due to the ease of understanding and use, also supports the most used programming languages, relatively speaking the costs are very low and also it provides excellent options in the Free Tier; and the best thing is that the possibilities of use are endless

Reference:

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

Rodrigo Zunino

Senior Software Engineer at VISA

3 年

????

要查看或添加评论,请登录

Kenility的更多文章