Which is better Redux-Thunk Or Redux-Saga
November 23, 2021Power BI : Recent Features: (2021)
May 12, 2022AWS – Lambda function
Lambda has become popular thanks to AWS. in this blog, we are going to shed some light on AWS Lambda, including how it binds into serverless architecture, how to create it, and when to use it.
Grasping serverless
To understand what AWS Lambda is, we must have knowledge of what serverless architecture is all about.
Serverless applications do not require any managing servers for them to run. When you run a serverless application, you don’t need to worry about OS setup, patching, and scaling of servers that you would have to worry about while running an application on a physical server.
The traits of serverless applications
- No server management
- Hostless
- Stateless
- Elasticity
- Distributed
- High availability
Various components of serverless applications
- Compute
- Storage
- API
- Orchestration
AWS offers services that can be used for each of these components that make up a serverless architecture. This is where AWS Lambda comes in.
Narrating AWS – Lambda
As defined by the AWS official source, “AWS Lambda is a compute service that lets you run code without provisioning or managing servers. It executes your code only when needed and scales automatically, from a few requests per day to thousands per second.”
Lambda speeds up the execution process and scales your application or code, by executing the events triggering a particular code.
When configuring a lambda function, you specify which runtime environment you’d like to run your code in. All environments are based on Amazon Linux AMI.
The current available runtime environments are:
- nodeJS
- Python
- Go
- Java
- Ruby
- .Net
- C#
Lambda configuration
- General configuration – Configure memory or opt in to the AWS Compute Optimizer. You can also configure function timeout and the execution role.
- Permissions – Configure the execution role and other permissions.
- Environment variables – Key-value pairs that Lambda sets in the execution environment. To extend your function’s configuration outside of code, use environment variables.
- Tags – Key-value pairs that Lambda attaches to your function resource. Use tags to organize Lambda functions into groups for cost reporting and filtering in the Lambda console.
- Virtual private cloud (VPC) – If your function needs network access to resources that are not available over the internet, configure it to connect to a virtual private cloud (VPC).
- Monitoring and operations tools – configure CloudWatch and other monitoring tools.
- Concurrency – Reserve concurrency for a function to set the maximum number of simultaneous executions for a function. manage concurrency to ensure that a function can scale without variation in latency. Reserved concurrency applies to the entire function, including all versions and aliases.
Create an AWS Lambda
- Login into your AWS account and click on “Sign in to the Console.”
- Enter your login ID and password.
- Select Lambda under “AWS Services”
- Click on “create function”
- Select following options and click on “Create Function” button
- Function Type
- Name
- Runtime(as above mentioned)
- Role
- Choose a way to upload/create code in the lambda function.
- you can write your code in the editor provided
- Handler name should be the same as your function name, this way AWS knows which function to execute.
- We can add more options like execution timeout, environment variables, tags.
- Click “Save.”
AWS Lambda use cases
- Operating serverless websites
- Rapid document conversion
- Predictive page rendering
- Working with external services
- Log analysis on the fly
- Automated backups and everyday tasks
- Processing uploaded S3 objects
- Backend cleaning
- Bulk real-time data processing