Serverless computing allows you to build and run applications and services without thinking about servers.
Key Concepts
- Functions as a Service (FaaS): Code is executed in stateless containers that are event-triggered, ephemeral, and fully managed by the cloud provider.
- Event-Driven: Functions are triggered by events such as HTTP requests, database modifications, or file uploads.
- Pay-per-use: You only pay for the compute time you consume - no charge when your code isn't running.
AWS Lambda Handler
The handler is the method in your function code that processes events. When your function is invoked, Lambda runs the handler method.
def lambda_handler(event, context):
# Your code here
return {
'statusCode': 200,
'body': 'Hello from Lambda!'
}
Execution Environment
Lambda runs your code in a secure, isolated execution environment. The environment includes:
- Runtime (Python, Node.js, Java, etc.)
- Memory allocation (128 MB to 10 GB)
- Timeout (up to 15 minutes)
- Temporary storage (/tmp directory, up to 10 GB)