Labs ICT
Pro Login

Lambda Introduction

What is AWS Lambda?

Lambda is AWS's serverless compute service. You write a function, upload it, and AWS runs it whenever it's triggered. No servers to manage, no operating systems to patch, no capacity planning required.

Imagine a vending machine: you put in your request (input), and it dispenses the result (output). You don't care how the machine works inside — you just care that it gives you what you asked for. That's Lambda in a nutshell.

How Lambda Works

You write your function in one of the supported languages (Python, Node.js, Java, Go, etc.), and Lambda runs it in response to events. An event could be an HTTP request, a file upload to S3, a database change, or a scheduled timer.

Lambda automatically scales — if 10,000 events come in at once, it spins up 10,000 copies of your function. You only pay for the time your code actually runs, measured in milliseconds.

Lambda Use Cases

Lambda is perfect for tasks that run occasionally or in response to specific events. Processing image uploads, sending notifications, running scheduled backups, or building REST APIs are all common use cases.

It's not ideal for long-running processes (max 15 minutes) or applications that need persistent connections. For those, use EC2 or ECS instead. Lambda shines when your workload is event-driven.

The Serverless Framework

Managing Lambda functions individually through the console gets tedious fast. The Serverless Framework lets you define your functions, triggers, and permissions in a YAML file.

serverless create --template aws-python3 --path my-function

This command scaffolds a new Lambda project. From there, you can deploy with a single command. It's like having a cheat sheet for your infrastructure.

Lambda Pricing

Lambda has a generous free tier: 1 million free requests and 400,000 GB-seconds of compute per month. For most side projects and small applications, you'll never pay a cent.

Even outside the free tier, Lambda is incredibly cost-effective. You're only charged for the exact time your code runs, rounded up to the nearest millisecond. No idle time, no wasted resources.