[For AWS beginners] Easy to understand in 5 minutes! AWS Lambda
table of contents
Hello!
This is Inoue, a Persian cat from Beyond Shikoku Office.
Today, we will explain about [Lambda], which is one of the representative AWS services.
What is Lambda?
Lambda is a service that enables serverless.
AWS provides an environment where you can run programs serverless.
As the name suggests, serverless does not mean that there is no server.
In reality, servers do exist, but since AWS takes care of building and maintaining servers,
users are freed from building and maintaining servers, and there is no need to manage servers at all.
Normally, in order to develop or run a program,
it is necessary to prepare a server and keep the server or instance running to run the program.
However, Lambda comes with an environment like the one above already prepared.
Therefore, users can focus on program development without worrying about server management.
Additionally, since usage fees are charged only when a program is executed, you can use Lambda with minimal costs.
This is an advantage over a resident server.
Lambda uses lean billing in milliseconds.
This means that you are charged for every millisecond that the function is executed.
You can use it for free until your function execution time reaches 400,000/sec per month.
However, the free time frame varies depending on the memory allocated to the Lambda function.
You will be charged for the number of requests, but you can use it for free up to 1 million requests per month.
You are not charged for Lambda creation or waiting time when the Lambda is not running.
AWS Lambda pricing
As you can see, the system is based on pay-as-you
Moreover, because Lambda operates in multiple Availability Zones within a region, it
can provide highly available and fault-tolerant operational performance.
We are able to provide excellent service without regular downtime or server outages.
This means that high availability and fault tolerance are maintained without the user being aware of it.
Lambda is a mechanism that automatically executes real-time processing of data and requests and backend processing.
Lambda automatically executes preset processes when an event occurs.
You can easily run Lambda by simply selecting the runtime of the program you want to run and uploading the source code.
Lambda does not require you to learn any special language; it supports common languages.
Therefore, there is no need to learn a new language to use Lambda, and you can start using Lambda immediately with the language you are familiar with.
Language support is increasing year by year and is expected to continue to increase.
Currently, the languages supported by Lambda include:
- C#
- PowerShell
- Go
- Java
- Node.js
- Python
- Ruby
If you would like to use a language other than those listed above, you can use custom runtime functionality.
Lambda functions are stored in a Lambda service.
It is executed on a specific AWS resource when some trigger occurs.
For example, when you upload an image to an S3 bucket, this triggers Lambda to resize the image and convert it into an image suitable for websites, etc.
The thumbnail creation function is called and the thumbnail can be created automatically.
■Service that calls Lambda
The service from which Lambda reads events | Kinesis, DynamoDB, SQS |
A service that calls Lambda functions synchronously | ELB, ALB, Cognito, Lex, Alexa, API Gateway, CloudFront, Kinesis Data Firehose |
A service that calls Lambda functions asynchronously | S3, SNS, SES, CloudFormation, CloudWatch Logs, CloudWatch Events, CodeCommit, Config |
If you use Lambda properly, you can create stable web applications at low cost.
Cooperation with AWS services
For example, Lambda can be triggered by the following events:
- When a specific time comes (CloudWatch Events)
- When data is uploaded to S3
- When a new item is written to DynamoDB
- When an Auto Scaling action is executed
- When a button is pressed on a web page
- when the API is called
- When you say "Alexa, tell me about ○○"
In this way, Lambda allows you to easily automate AWS processing.
No need to manage servers
As mentioned above, Lambda is serverless and does not require server management.
Therefore, you are freed from server operations and can focus on developing program code.
This eliminates the need for server management such as:
- Operating system updates
- Applying security patches
- Add disk space
- Operating system and middleware maintenance
- Redundancy, recovery in case of failure
- Ensuring scalability
- Design for disability
- Retry on execution error
- Consideration that jobs are concentrated at specific times
Also, Lambda will not execute the process unless there is an execution instruction such as a request or trigger.
Unlike a resident server, there is no need to keep it running while waiting for requests or triggers.
Code is executed only when a request or trigger occurs.
If two requests occur at the same time, the two Lambda functions will be executed at the same time.
As the number of requests increases, the number of times the Lambda function will be executed will increase accordingly, but
Lambda will automatically ensure scalability without configuring Auto Scaling.
This scales horizontally and runs Lambda functions in parallel depending on the number of requests.
Therefore, there is no need to configure Auto Scaling.
By default, there is a limit of 1,000 concurrent executions of Lambda functions for the entire account, but
if you need more than 1,000 concurrent executions, you can request an increase in the number of concurrent executions.
Additionally, you can set an upper limit on the number of concurrent executions for each Lambda function.
Finally
This time, you can learn about Lambda in 5 minutes! I gave you a rough explanation, what do you think?
I thought it was a good idea that you are charged when an event or trigger is executed, but you are not charged for waiting time!
Lambda also has high fault tolerance and high availability.
The fact that failures are less likely to occur means that applications can run reliably.
In this way, every time I write a blog about AWS, I am convinced of the popularity of the AWS cloud.
I would like to continue writing a blog with a rough explanation of AWS services, so I would be happy if you could read it.
Growing every day, moving forward every day.
I have to update myself every day! ! !
Thank you for reading to the end.