Posts

AWS Lambda in 5 minutes

Updated: Apr 29





Today's topic is Lambda, one of the most popular AWS services.



What is Lambda?

Lambda is a service that you can execute programs in a serverless manner.

The word "serverless" might be confusing but it does not mean "without servers". In fact, there is a server, but users are free from the need to build and maintain servers and do not need to manage servers at all since AWS takes care of the construction and maintenance of the server.


In order to develop and run a program, you normally need to prepare a server and keep running the prepared server to execute the program.

However, with Lambda, the above environment is prepared already, so users can focus on program development without worrying about server management.


In addition, Lambda can be used at minimal cost because the usage fee is incurred only when the program is executed. This is an advantage over resident servers.

Lambda is free to use up to 400,000 per second per month to execute a function although the amount of free time depends on the memory allocated to the Lambda function.

You will also be charged for the number of requests you make, but you can use it for free up to 1 million requests per month. You will not be charged for Lambda creation and waiting time when Lambda is not running.

This type of pricing provides greater cost benefits, especially for larger systems.


See the official pricing


Moreover, Lambda is highly available and can provide fault-tolerant operational performance because it runs in multiple availability zones within a region.

There is no periodic downtime or server outages, which results in excellent service delivery.


Lambda is a mechanism to automatically execute real-time processing of data and requests as well as back-end processing. You can easily run Lambda by simply selecting the runtime of the program you want to run and uploading the source code.

Currently, Lambda supports C#, PowerShell, Go, Java, Node.js, Python, and Ruby. And if you want to use a language other than the above, you can use the custom runtime feature.


Lambda functions are stored in the Lambda service and are executed on specific AWS resources when triggered. Lambda functions are stored in the Lambda service and are executed on specific AWS resources when triggered.

For example, uploading an image to an S3 bucket triggers Lambda to resize the image and convert it to an image suitable for a website.


■Service to invoke Lambda

Service Type

Service Name

Service where Lambda reads events

Kinesis, DynamoDB, SQS

Service to call Lambda functions synchronously

ELB, ALB, Cognito, Lex, Alexa, API Gateway, CloudFront, Kinesis Data Firehose

Service to call Lambda functions asynchronously

S3, SNS, SES, CloudFormation, CloudWatch Logs, CloudWatch Events, CodeCommit, Config



Linking with AWS services

Lambda can be triggered by events such as the following.

  • At a specific time (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 an API is called

  • When you say "Alexa, tell me about ____".



Free From Server Management

As mentioned above, Lambda is serverless and does not require server management.

You will be free from managing servers such as the following and will be able to focus on developing program code.

  • Upgrading the operating system

  • Applying security patches

  • Adding disk space

  • OS and middleware maintenance

  • Redundancy, recovery in case of failure

  • Ensuring scalability

  • Designing with failures in mind

  • Retry in case of execution errors

  • Consideration for the concentration of jobs at specific times


Also, since Lambda does not execute any process when there is no execution instruction such as a request or trigger, it does not need to keep running while waiting for a request or trigger like a resident server. The code will be executed only when a request or trigger occurs and if two requests occur at the same time, then those two Lambda functions will be executed at the same time.


As the number of requests increases, so does the number of times the Lambda function is executed, but scalability is automatically ensured without the need for Auto Scaling settings since Lambda horizontally scales according to the number of requests and the Lambda function is executed in parallel.


By default, there is a limit of 1,000 concurrent Lambda functions for the entire account, but you can request a higher concurrency limit if you need more. You can also set an upper limit on the number of concurrent executions for each Lambda function.




Summary

Overall, AWS Lambda is a pretty useful feature for AWS users. The high fault tolerance and availability of Lambda are also attractive. It will only charge you when events and triggers are executed, and not charged for waiting time. It would be recommended to any scale of an organization from individual developers to a big company.





This blog post is translated from a blog post written by Tomoka Inoue on our Japanese website Beyond Co..