# AWS Lamda

### What’s serverless?

* Serverless is a new paradigm in which the developers don’t have to manage servers anymore...
* They just deploy code
* They just deploy... functions !
* Initially... Serverless == FaaS (Function as a Service)
* Serverless was pioneered by AWS Lambda but now also includes anything that’s managed: “databases, messaging, storage, etc.”
* Serverless does not mean there are no servers... it means you just don’t manage / provision / see them

### Why AWS Lambda

<figure><img src="https://1722711354-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwNXdoUkfmcozr29fRrfb%2Fuploads%2FQt5d3MvtL8V0DZPqrFRZ%2FScreenshot%202023-12-14%20at%2000.08.51.png?alt=media&#x26;token=0d978c7b-5950-4aec-a9c5-03c815fa9afc" alt=""><figcaption></figcaption></figure>

### Benefits of AWS Lambda

• Easy Pricing:

* Pay per request and compute time
* The free tier of 1,000,000 AWS Lambda requests and 400,000 GBs of compute time

• Integrated with the whole AWS suite of services

• Event-Driven: functions get invoked by AWS when needed

• Integrated with many programming languages

• Easy monitoring through AWS CloudWatch

• Easy to get more resources per function (up to 10GB of RAM!)&#x20;

• Increasing RAM will also improve CPU and network!

### AWS Lambda language support

• Node.js (JavaScript)

• Python

• Java (Java 8 compatible)

• C# (.NET Core)

• Golang

• C# / Powershell

• Ruby

• Custom Runtime API (community supported, for example Rust)

• Lambda Container Image

* The container image must implement the Lambda Runtime API&#x20;
* ECS / Fargate is preferred for running arbitrary Docker images

#### Example: Serverless Thumbnail creation

<figure><img src="https://1722711354-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwNXdoUkfmcozr29fRrfb%2Fuploads%2F8t7jPKfAmxFCBdKMRGHa%2FScreenshot%202023-12-14%20at%2000.11.55.png?alt=media&#x26;token=2e6c5407-2929-4d64-bec7-f45c93bc5b03" alt=""><figcaption></figcaption></figure>

#### Example: Serverless CRON Job

<figure><img src="https://1722711354-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwNXdoUkfmcozr29fRrfb%2Fuploads%2FcvA5lnrdKrIC9pRW0gun%2FScreenshot%202023-12-14%20at%2000.12.18.png?alt=media&#x26;token=492a14e0-30d8-4447-8dc8-b13e0383589f" alt=""><figcaption></figcaption></figure>

### AWS Lambda Pricing

* You can find overall pricing information here: <https://aws.amazon.com/lambda/pricing/>
* Pay per calls:
  * The first 1,000,000 requests are free
  * $0.20 per 1 million requests thereafter ($0.0000002 per request)
* Pay per duration: (in increments of 1 ms)

  * 400,000 GB-seconds of compute time per month for FREE&#x20;
  * \== 400,000 seconds if the function is 1GB RAM
  * \== 3,200,000 seconds if the function is 128 MB RAM
  * After that $1.00 for 600,000 GB-seconds

  \=> It is usually very cheap to run AWS Lambda so it’s a very popular
