AWS Lambda Basics
Understand the basics of AWS Lambda.
- Lets you run code without provisioning or managing servers.
- Pay only for the compute time you consume
- No charge when code is not running.
- Run code for virtually any type of application or backend service – with zero administration.
- Scales application by running code in response to each trigger.
- Code runs in parallel and processes each trigger individually
- Scaling precisely with the size of the workload.
- Charged for every 100ms code executes and the number of times code is triggered.
Lambda Working
- Lambda runs functions in a serverless environment to process events.
- Each instance of function runs in an isolated execution context
- one event at a time is processed.
- After finishing event processing, a response is returned and Lambda sends it another event.
Lambda Components
- Function – A script or program that runs in AWS Lambda. Lambda passes invocation events to function. The function processes an event and returns a response.
- Runtimes – Lambda runtimes allow functions in different languages to run in the same base execution environment. You configure function to use a runtime that matches programming language. The runtime sits in-between the Lambda service and function code, relaying invocation events, context information, and responses between the two. You can use runtimes provided by Lambda, or build own.
- Layers – Lambda layers are a distribution mechanism for libraries, custom runtimes, and other function dependencies. Layers let you manage in-development function code independently from the unchanging code and resources that it uses. You can configure function to use layers that you create, layers provided by AWS, or layers from other AWS customers.
- Event source – An AWS service, such as Amazon SNS, or a custom service, that triggers function and executes its logic.
- Downstream resources – An AWS service, such as DynamoDB tables or Amazon S3 buckets, that Lambda function calls once it is triggered.
- Log streams –Lambda monitors function invocations and reports metrics to CloudWatch. Annotate function code with custom logging statements to analyze the execution flow and performance of Lambda function to ensure it’s working properly.
- AWS SAM – A model to define serverless applications. AWS SAM is natively supported by AWS CloudFormation and defines simplified syntax for expressing serverless resources.
Lambda function configuration, deployments, and execution limits
Resource | Limit |
Function memory allocation | 128 MB to 3,008 MB, in 64 MB increments. |
Function timeout | 900 seconds (15 minutes) |
Function environment variables | 4 KB |
Function resource-based policy | 20 KB |
Function layers | 5 layers |
Invocation frequency (requests per second) | 10 x concurrent executions limit (synchronous – all sources) 10 x concurrent executions limit (asynchronous – non-AWS sources) Unlimited (asynchronous – AWS service sources) |
Invocation payload (request and response) | 6 MB (synchronous) 256 KB (asynchronous) |
Deployment package size | 50 MB (zipped, for direct upload) 250 MB (unzipped, including layers) 3 MB (console editor) |
Test events (console editor) | 10 |
/tmp directory storage
| 512 MB |
File descriptors | 1,024 |
Execution processes/threads | 1,024 |
AWS Lambda-based application lifecycle
- authoring code
- deploying code to AWS Lambda
- monitoring and troubleshooting
AWS Lambda supported languages, their tools and options
Language | Tools and Options for Authoring Code |
Node.js | AWS Lambda consoleVisual Studio, with IDE plug-in own authoring environment |
Java | Eclipse, with AWS Toolkit for Eclipse IntelliJ, with the AWS Toolkit for IntelliJown authoring environment |
C# | Visual Studio, with IDE plug-in .NET Core own authoring environment |
Python | AWS Lambda consolePyCharm, with the AWS Toolkit for PyCharmown authoring environment |
Ruby | AWS Lambda consoleown authoring environment |
Go | own authoring environment |
PowerShell | own authoring environmentPowerShell Core 6.0 .NET Core 2.1 SDK AWSLambdaPSCore Module |
AWS Certified DevOps Engineer Free Practice TestTake a Quiz