- AWS Lambda is a compute service that lets you run code without provisioning or managing servers.
- AWS Lambda runs your code on a high-availability compute infrastructure and performs all the administration of compute resources, including server and operating system maintenance, capacity provisioning and automatic scaling, code monitoring and logging.
- With Lambda, you can run code for virtually any type of application or backend service, including data processing, real-time stream processing, machine learning, WebSockets, IoT backends, mobile backends, and web apps, like your corporate directory app!
Feature | Remarks |
---|---|
Stateless | Lambda is stateless, so it won't remember who a user is in between requests. |
Function blueprints | When you create a function in the Lambda console, you can choose to start from scratch, use a blueprint, or use a container image. - A blueprint provides sample code that shows how to use Lambda with an AWS service or a popular third-party application. - Blueprints include sample code and function configuration presets for Node.js and Python runtimes. |
IAM Permissions | |
Scaling Considerations | |
Encryption at rest | Lambda Handler, Layer, Environment Variables are stored encrypted. |
Networking | Lambda functions always operate from an AWS-owned VPC. |
Test locally using AWS SAM CLI | AWS SAM CLI can be used to test the Lambda function locally. |
Billing granularity | You are charged for the number of times your code is triggered (requests) and for the time your code executes, rounded up to the nearest 1 ms (duration). - It can be cost effective to run functions whose execution time is very low, such as functions with durations under 100 ms or low latency APIs. aws-lambda-power-tuning can be helpful for lambda billing estimation (to balance power & duration). |
AWS Lambda Invocation Methods | |
Tags | You can tag AWS Lambda functions to activate attribute-based access control (ABAC) and to organize them by owner, project, or department. - Tags are free-form key-value pairs that are supported across AWS services for use in ABAC, filtering resources, and adding detail to billing reports. |
Processor Architecture - ARM vs x86 | ARM processor is bit cheaper than x86 processor |
Schedule expressions using rate or cron | AWS Lambda supports standard rate and cron expressions for frequencies of up to once per minute. - EventBridge (CloudWatch Events) rate expressions are simpler to define but do not offer the fine-grained schedule control that cron triggers support. |
Config | Type | Limit | Remarks |
---|---|---|---|
⭐ Memory | General | - | Example - 512 MB - Over provision memory to run your functions faster and reduce your costs (since cost is calculated based on compute time). |
⭐ Timeout | General | Max 15 mins | Example - 20 sec - Do not over-provision your function timeout settings. - If its greater than 15 mins, AWS Step Functions might be better choice. |
Ephemeral storage | General | - | Example - 512 MB |
Batch Size | General | 1 to 10 | Number of messages that can be in a batch |
Number of default pollers (batches returned at one time) | General | 5 | - |
Lambda Handler | Code | No limit | - |
Lambda layer | Code | No limit | A Lambda layer is a .zip file archive that can contain additional code or other content, like libraries, config files etc. |
AWS KMS key | Environment Variable | - | - |
- AWS Lambda is an example of an event-driven architecture.
- Most AWS services generate events and act as an event source for Lambda.
- Lambda runs custom code (functions) in response to events.
- Lambda functions are designed to process these events and, once invoked, may initiate other actions or subsequent events.
- Backup Jobs - Lambda can be used to configure backup scripts for the application.
- Automatic Jobs - Shutdown AWS resources at certain time.
Feature | Description |
---|---|
Tracing of Lambda using AWS X-Ray | AWS X-Ray can be used to trace Lambda code. - You can use AWS X-Ray to visualize the components of your application, identify performance bottlenecks, and troubleshoot requests that resulted in an error. |
Logging Lambda API calls with CloudTrail | AWS Cloudtrail can be used to monitor invocations of Lambda functions. |
Lambda logging (stored in CloudWatch Logs) | Lambda logs all requests handled by your function and automatically stores logs generated by your code through Amazon CloudWatch Logs. - To validate your code, instrument it with custom logging statements. |
Tool | Description |
---|---|
AWS Lambda Power Tuning | AWS Lambda Power Tuning is a state machine powered by AWS Step Functions that helps you optimize your Lambda functions for cost and/or performance in a data-driven way. |