I am Specialized Sharing interesting articles and news articles.
What is AWS Lambda?
AWS Lambda is an event-driven, serverless computing platform provided by Amazon as a part of Amazon Web Services. Therefore you don't need to worry about which AWS resources to launch, or how will you manage them. Instead, you need to put the code on Lambda, and it runs.
In AWS Lambda the code is executed based on the response of events in AWS services such as add/delete files in S3 bucket, HTTP request from Amazon API gateway, etc. However, Amazon Lambda can only be used to execute background tasks.
AWS Lambda function helps you to focus on your core product and business logic instead of managing operating system (OS) access control, OS patching, right-sizing, provisioning, scaling, etc.
AWS Lambda helps you to upload code and the event details on which it should be triggered.
AWS charges only when the AWS lambda code executes.
One will be charged for AWS services only when the AWS Lambda code executes
Events that Trigger AWS Lambda
Events which will be triggered when you use AWS Lambda.
- Insert, updating and deleting data Dynamo DB table
- To include push notifications in SNS
- To search for log history in CloudTrail
- Entry into an S3 object
- DynamoDB can trigger AWS Lambda whenever there is data added, modified, and deleted in the table.
- Helps you to schedule the event to carry out the task at regular time pattern.
- Modifications to objects in S3 buckets
- Notifications sent from Amazon SNS.
- AWS Lambda can be used to process the CloudTrail logs
- API Gateway allows you to trigger AWS Lambda on GET/POST methods.
AWS Lambda Concepts
A function is a program or a script which runs in AWS Lambda. Lambda passes invocation events into your function, which processes an event and returns its response.
Runtime allows functions in various languages which runs on the same base execution environment. This helps you to configure your function in runtime.
An event source is an AWS service, such as Amazon SNS, or a custom service. This triggers function helps you to executes its logic.
Lambda layers are an important distribution mechanism for libraries, custom runtimes, and other important function dependencies. This AWS component also helps you to manage your development function code separately from the unchanging code and resources that it uses.
Log stream allows you to annotate your function code with custom logging statements which helps you to analyse the execution flow and performance of your AWS Lambda functions.
Best practices of Lambda function:
- Use the right "timeout."
- Utilize the functions of local storage which is 500MB in size in the /temp folder
- Minimizing the use of start-up code which is not directly related to processing the current event.
- You should use built-in CloudWatch monitoring of your Lambda functions to view and optimize request latencies.
Advantages of using AWS Lambda
- Serverless is a term that generally refers to serverless applications.
- AWS Lambda is one such serverless compute service. Therefore, you don't need to worry about which AWS resources to launch, or how will they manage them.
- A function is a program or a script which runs in AWS serverless Lambda.
- Runtime allows functions in various languages which runs on the same base execution environment.
- An event source is an AWS service, such as Amazon SNS, or a custom service.
- Lambda layers are an important distribution mechanism for libraries, custom runtimes, and other important function dependencies.
- Log stream allows you to annotate your function code with custom logging statements which helps you to analyse the execution flow and performance of your Lambda functions.
- AWS Lambda is a Platform as a Service (PaaS). It helps you to run and execute your backend code.
- AWS EC2 Is an Infrastructure as a Service (laaS). It provides virtualized computing resources.
- Deploy and manage the apps on AWS Cloud without worrying about the infrastructure which runs those applications.
- AWS Lambda is used for running and executing your Back-end code. You can't use it to deploy an application.
- AWS Lambda helps you for the ETL process.
- The best practice of Lambda function in AWS is to use the right "timeout."
- It is not appropriate to use AWS Lambda software packages or applications which rely on calling underlying Windows RPCs
- AWS Lambda is a highly flexible tool.
- AWS Lambda tool is not suitable for small projects.
- A common event which will be triggered when you use AWS Lambda is Insert, updating and deleting data Dynamo DB table.