What is AWS Lambda and how does it differ from EC2?
AWS Lambda is a serverless compute service that runs code in response to events.
EC2:
* You manage servers
Lambda:
* No server management
* Runs code automatically when triggered
What does “serverless” actually mean in Lambda?
You don’t manage infrastructure — AWS handles provisioning, scaling, and maintenance.
What is an event-driven architecture in Lambda?
Code runs only when triggered by an event (e.g., file upload, API call).
Give examples of AWS Lambda event sources.
Describe the flow when a file is uploaded to S3 and triggers Lambda.
File uploaded to S3
Event notification sent
Lambda function triggered
Code executes
Output stored/logged
What is the role of API Gateway with Lambda?
It allows Lambda to be triggered via HTTP requests, enabling APIs.
Why is Lambda ideal for microservices architectures?
Because functions are:
* Independent
* Scalable
* Event-driven
How does Lambda scale automatically?
AWS automatically creates multiple function instances based on incoming events.
What is a key benefit of Lambda in terms of cost?
You only pay for:
* Execution time
* Number of requests
(No cost when idle)
What is the Lambda pricing model based on?
Why is Lambda considered cost-efficient?
Because there is no charge when the function is not running.
What is the maximum execution time for a Lambda function?
15 minutes
What happens if a Lambda function exceeds its execution time?
It is terminated automatically.
What is the deployment package in Lambda?
A ZIP file containing:
* Code
* Dependencies
What languages are supported by Lambda?
Common ones include:
* Python
* Node.js
* Java
* C#
What is IAM’s role in Lambda?
It controls permissions, allowing Lambda to access other AWS services securely.
Why must Lambda functions have IAM roles?
To grant secure access to resources like S3, DynamoDB, etc.
What is concurrency in Lambda?
The number of function instances running simultaneously.
What happens when many events trigger Lambda at once?
Lambda automatically scales to handle multiple concurrent executions.
What is a common limitation of Lambda?
When should Lambda NOT be used?
A user uploads images that need resizing automatically. What should be used?
S3 trigger + Lambda
A REST API backend is needed without managing servers. Best solution?
API Gateway + Lambda
An application runs continuously for hours. Should Lambda be used? Why?
No.
Because Lambda has a 15-minute execution limit.