Understanding AWS Lambda
-
Understanding AWS Lambda
Let us start understanding AWS Lambda with various features, working, and important terms.
- compute service to run code
- No need to provision/manage servers, even on AWS with no server administration
- code is executed when needed
- automatic scaling as per code requests
- payment for compute time consumed
- execute code for any software application
- automatically does
- compute resource administration
- server and OS maintenance
- capacity provisioning
- scaling
- code monitoring
- logging
- tightly integrated with other AWS service like S3
- code executed against event trigger like change in S3 table
- execute custom code by using APIs
- create serverless applications
- Lambda functions execute in serverless environment for event processing
- Every Lambda function instance is executed in isolated context
Lambda Working
- one event at a time is processed.
- Lambda service receives an event trigger
- Lambda service instantiates the associated code to process event
- Response is sent by Lambda service, after execution completes
- Lambda service waits for another event.
Important terms
- Function – code block/script/program which Lambda executes. events passed to it by AWS and response taken
- Runtimes – provide execution environment as per programming language. Available for different languages. Is between Lambda service and Lambda function
- Layers – to distribute libraries/custom runtimes/function dependencies
- Event source – Are AWS service which trigger Lambfa function to run it
- Downstream resources – Are AWS services called by Lambda function. usually DynamoDB tables/S3 buckets
- Log streams – custom logging statements of Lambda function code by annotation
- SAM – Or Serverless Application Model for defining serverless applications.
Lambda working
Use case of automatic resizing of uploaded image
Lambda limits
Resource | Limit |
Total Function memory allocation | 128 MB to 3,008 MB, in 64 MB increments. |
Total Function timeout | 900 seconds (15 minutes) |
Total Function environment variables | 4 KB |
Total Function resource-based policy size | 20 KB |
Total Function layers | 5 layers |
Maximum Invocation frequency (requests per second) | 10 times the concurrent executions limit for synchronous from all sources 10 times the concurrent executions limit for asynchronous from non-AWS sources Unlimited for asynchronous from AWS service sources |
Total Invocation payload (sum of both request and response) | 6 MB for synchronous and 256 KB for asynchronous |
Total size of deployment package | 50 MB maximum for zipped and for direct upload 250 MB for unzipped even including layers 3 MB for console editor |
Count of Test events (console editor) | 10 |
Total, /tmp directory storage | 512 MB |
Count of File descriptors | 1,024 |
Count of Execution processes/threads | 1,024 |
AWS Lambda-based application lifecycle
- Develop the code
- deploy the developed and tested code to AWS Lambda
- monitor for performance
- troubleshoot if any error
- 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 environment PowerShell Core 6.0 .NET Core 2.1 SDK AWSLambdaPSCore Module |
Get ready to pass the AWS Certified Developer – Associate Practice Exam with practice exam Now!
AWS Certified Developer - Associate Free Practice TestTake a Quiz