What You Will Learn
Intermediate
- What Lambda is and how it works
- When to use Lambda vs EC2
- How to create a Lambda function
AWS Lambda lets you run code without provisioning servers. Upload your code, set a trigger, and AWS handles everything — scaling, OS, patches. Pay per execution (ms).
Always free tier
Lambda gives you 1 MILLION free requests per month, forever. Perfect for APIs, cron jobs, and event processing.| Aspect | EC2 | Lambda |
|---|---|---|
| You manage | OS, patches, scaling | Nothing |
| Scaling | Manual or Auto Scaling | Automatic |
| Pricing | Per hour (running or not) | Per ms of execution |
| Max runtime | Unlimited | 15 minutes |
| Best for | Long-running servers | Short tasks, APIs, events |
Lambda function (Python)python
def lambda_handler(event, context):
return {
'statusCode': 200,
'body': 'Hello from Lambda!'
}Practical Exercise
Go to Lambda in AWS Console
Create a function -> Author from scratch
Choose Python 3.11, hello-world blueprint
Click "Test" to run it
See the output in the console
Key Takeaways
- Lambda = run code without managing servers.
- Pay per ms of execution. 1M free requests/month forever.
- Automatic scaling. No OS to patch.
- Max runtime: 15 minutes per invocation.
- Best for: APIs, event processing, cron jobs.
Comments
Comments
Post a Comment