AWS Lambda
Learn about AWS Lambda, a serverless computing service.
We'll cover the following
Introduction
AWS Lambda is a serverless computing service that lets us run code without provisioning or managing servers. We can simply upload our code to the service, where it automatically runs in a highly scalable computing infrastructure managed by AWS.
Note: The term “serverless” is used to describe an architecture style for building and running applications and services without having to manage the underlying infrastructure. In this type of architecture, cloud providers such as AWS are responsible for managing the servers, storage, and networking. As users, we just need to upload our code and set up triggers to invoke it. This allows developers to focus on writing code rather than worrying about infrastructure.
When we run our application code, we usually provision computing and storage resources (EC2, EBS, EFS, etc.) to deploy and run our application on these resources.
AWS Lambda allows us to run our code without having to worry about the underlying infrastructure. The term serverless doesn’t mean that servers don’t exist. It means that we, as users, never have to care about the resources on which our code runs. The Lambda service automatically runs our code on appropriate hardware and scales with incoming request traffic, allowing us to build and run highly reliable and scalable applications. Lambda allows us to create functions that are meant for short executions (maximum execution time is 15 minutes).
Features
Here are some of the key features of AWS Lambda:
- Automatic scaling: Lambda automatically scales our application by running multiple instances of a function in response to incoming requests.
- Pay-per-use pricing model: We pay only for the computing time we consume in increments of 100 milliseconds.
- Easy integration: Lambda integrates with several other AWS services, like S3, DynamoDB, and API Gateway, allowing us to build serverless applications. It’s also commonly used to automate AWS management tasks in response to CloudWatch or EventBridge events.
- Flexible triggers: Lambda functions can be triggered by events such as changes to data in an S3 bucket (S3 Event Notifications) or a new line of a log file delivered to CloudWatch Logs.
- Secure execution environment: Lambda provides a secure and reliable execution environment with multiple layers of security, including network isolation, VPCs, and IAM roles.
- No infrastructure management: With AWS Lambda, we don’t have to manage infrastructure, such as servers, OS, or runtime environments.
- Monitoring: Lambda logs and metrics are captured in CloudWatch.
- Hardware improvement: Although Lambda doesn’t allow us to control the hardware on which our functions run, we can specify RAM for our Lambda functions. Increasing the RAM of a function will automatically improve the CPU and network capacity.
- Language support: Lambda supports the following programming languages. It provides a runtime API, which allows us to use any additional programming languages to author our functions.
- JAVA
- Go
- PowerShell
- Node.js
- C#
- Python
- Ruby
- Environment variable support: We can use environment variables to provide values to a function.
- Environment variables can be used to provide secure values like database username and password.
- They can be encrypted to allow only trusted users with higher privileges to view and update them.
Points to note:
- Lambda function RAM values range from 128 MB to 10 GB.
- The default execution time of a Lambda function is three seconds. This value can be increased to up to 900 seconds (15 minutes).
- The maximum size of Lambda function deployment (function code and dependencies) can be 50 MB when compressed (as
.zip
or.tar
, etc.) and 250 MB when decompressed. - The maximum size of environment variables is 4 KB.
- To use storage in Lambda functions, we can use the
/tmp
directory (512 MB–10 GB storage). This folder should only be used as temporary storage during the function execution. Once the execution completes, all data in the folder will be lost.
Get hands-on with 1400+ tech skills courses.