AWS Lambda (PaaS)
AWS Lambda is a serverless computing service. It let you run your code without worrying about provisioning and managing servers and it also scales automatically depending on the traffic. You can run any type of application supported by Lambda function(Python, Java, Go, C#, PowerShell, Ruby, Node JS) with zero administrators and pay only for the compute time that you consume and no pay for idle server time.
AWS Lambda manages the following activities:
provision server and maintain OS (apply os updates and security patches)
Highly available and scales automatically
deploy your code
Monitor and log your lambda function
Lambda Function: After the lambda is invoked by the event, it will execute the lambda function, which contains the application code.
AWS Lambda can be triggered by an event. This event source can be any other AWS service such as SQS, Kinesis Data Streams, API Gateway, etc. It works on Push and Pull mechanism.
Different ways of invoking Lambda Function:
Push Model Source Type:
1.1 Synchronous invoke (Push based):
Lambda returns the response back to the event source.
services that invoke lambda function synchronously are ELB, Amazon Cognito, CloudFront, CloudFormation, API Gateway, Amazon Lex, Kinesis Data Firehose, etc
1.2 Asynchronous invoke (Event based):
Once the event source gets the acknowledgment from Lambda, now it's up to Lambda to process the event and Lambda does not return the message back to the event source.
If there is any error then Lambda tries 3 times (1st try then wait for 1 minute and then tries 2nd times if it fails again then it waits for 2 mins before trying for 3rd and last times and if fails 3 times also then can configure lambda to save it to a Dead letter Queue )
As lambda can not send responses back to event sources but can send the information to other services called as a Destinations. It can be SQS, SNS, Lambda, and EventBridge.
Based on the lambda info you can choose destination service. If there is any error then you can send a message to EventBridge for monitoring. If the code runs successfully then you can send it to the SNS service.
services that invoke asynchronously are Amazon S3, SNS, SES, Cloudwatch logs, Cloudwatch events, Code Commit, AWS Config
- Pull Model:
Lambda will poll the services (stream- DyanmoDB & Kinesis Data Stream and queues- SQS)on your behalf, retrieve records and invoke the lambda function.
supported services such as Amazon Kinesis, Amazon SQS, Amazon DynamoDB Streams
How to Configure Lambda?
AWS Management Console
AWS CLI
SDK
AWS CloudFormation
AWS Serverless Application Model
Components of Lambda Functions and its Pricing
Configuring Lambda
Access Permissions
Monitoring Options
Lambda is automatically configured with AWS CloudWatch for monitoring the functions metrics such as the number of requests, number of requests with errors, innovation durations of requests, lambda throttles, number of events in dead letter queue, and many more metrics. It provides aggregated information about the functions and thus helps in troubleshooting, identifying the issues.
It can also integrate with AWS X-Ray Services for monitoring and troubleshooting by providing a visual map for viewing performance bottlenecks and tracing lambda function paths.
Subscribe to my newsletter
Read articles from Anjali Barodia directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Anjali Barodia
Anjali Barodia
Python backend developer with expertise in DevOps, AWS, and ML.