What is AWS Lambda? (original) (raw)
AWS Lambda is an event-driven cloud computing service from Amazon Web Services (AWS) that allows developers to run code without having to provision, administer, or manage compute resources. This service is one well-known example of serverless architecture as well as a popular cloud computing concept called function as a service (FaaS).
Benefits of AWS Lambda
One of the main benefits of AWS Lambda is that it enables development teams to run code in response to events, such as HTTP requests via Amazon Application Programming Interface Gateway (Amazon API Gateway), without worrying about the management of servers and other infrastructure. With this service, Amazon manages the servers, maintains the operating system, provisions capacity, deploys code and security patches, monitors and logs code, and takes care of automatic scaling and logging. This allows developers to focus on writing application code and quickly move code from ideation to production.
Ultimately, by running code on highly available and fault-tolerant compute infrastructure and managing all underlying compute resources, Lambda enables dev teams to build serverless applications faster than they would be able to do otherwise.
Moreover, they can upload the code as a ZIP file or container image. To create a container image for a Lambda function, developers can use either an AWS-provided base image or an alternative base image. This allows for the reuse of existing and familiar container tools and workflows. This also supports larger workloads with sizable dependencies, such as machine learning (ML).
Automatic scaling is another key benefit of AWS Lambda. The service scales automatically and responds to many code execution requests, whether the requirement is for a dozen events per day or hundreds of thousands of events per second. It can also scale down to zero when there is no demand. For this reason, Lambda is a useful compute service for developing applications that require fast scaling up or down.
AWS Lambda functions are a small piece of a program that carries out a specific task. An AWS resource, such as an Amazon S3 bucket, is created. Then a Lambda function and a Lambda trigger are created. When objects are added to or removed from the bucket, it invokes the function and outputs the object type to the CloudWatch Logs.
Key features of AWS Lambda
AWS Lambda includes numerous features in a simple, serverless FaaS avatar. A popular one is completely automated administration, which allows developers to build differentiated backend services instead of spending time on infrastructure management.
Built-in fault tolerance is another advantageous feature of AWS Lambda. Since Lambda maintains compute capacity across multiple Availability Zones in each AWS Region, it protects code integrity even if individual machines or entire data centers fail. Also, auto-scaling scales to support any number of incoming requests without any manual configuration and within just a few milliseconds of an event. The code is stateless, so any number of instances can be started without lengthy deployment times or configuration delays.
AWS Lambda includes provisioned concurrency -- a feature that can be turned on or off by users -- which ensures that functions remain initialized and ready to respond in double-digit milliseconds. This feature is useful for latency-sensitive applications requiring greater control over function start time. It ensures consistent performance of serverless applications without the need for Lambda users to manage compute resources or make major code changes.
Lambda includes numerous security features to protect code from unauthorized access or actions. For example, its built-in software development kit integrates with AWS IAM to ensure secure code access to other AWS services. Also, all code runs within an Amazon Virtual Private Cloud to ensure secure Lambda function access to resources. Further, Lambda's code signing feature ensures that only unaltered code published by approved developers is deployed in Lambda functions.
What can you do with AWS Lambda?
AWS Lambda functions
In computer programming, a function is a small piece of a program that carries out a specific task. Developers can use AWS Lambda to run code and organize it into Lambda functions in response to specific events. Such event-driven functions facilitate easy and seamless communication between decoupled services.
Users can coordinate multiple functions for complex tasks by building AWS Step Functions workflows. These workflows trigger functions using sequential, parallel, branching, and error-handling steps, which can be useful for setting up stateful, long-running processes for applications and backends.
Lambda runs functions only when needed, so organizations incur no cost when the code is not running. The service also handles all function-associated administrative and operational activities, including capacity monitoring and management, and function logging. Additionally, Lambda includes tools for monitoring, observability, security and governance that enable teams to further augment Lambda functions and develop useful, extensible Lambda applications.
Using AWS Lambda and code functions, developers can do the following:
- Develop scalable and secure Lambda applications by using environment variables to adjust a function's behavior instead of having to update code.
- Add dedicated HTTP/HTTPS endpoints to Lambda functions.
- Improve time-to-first-byte performance or return larger payloads by configuring the URLs of Lambda functions so they stream response payloads back to clients from Node.js functions
- Sign code to ensure that only approved personnel can publish unaltered, trusted code in each function,
- Get function code to access and modify shared resources safely by configuring the function to mount an Amazon Elastic File System (EFS) to a local directory.
- Optimize the function memory size to optimize code execution time and performance.
Each Lambda function runs in an isolated computing environment with its own resources and view of the file system.
When AWS Lambda functions are called, the storage and compute resources for that function spin up automatically as a metered service.
AWS Lambda lets you run code without provisioning or managing servers. You pay only for the compute time you consume; there is no charge when your code is not running.
With Lambda, you can run code for virtually any type of application or backend service. Just upload your code, and Lambda takes care of everything required to run and scale your code with high availability. You can set up your code to automatically trigger from other AWS services or call it directly from any web or mobile app.
AWS supports code written in a variety of programming languages. AWS Lambda languages include Node.js, Python, Java and C#. Developers can also use Lambda's Runtime API to author functions using other languages. They can use third-party libraries, package code as a Lambda Layer, and easily manage and share code across multiple functions.
To create and use AWS Lambda functions, developers need to follow this three-step process:
- Create the function by uploading the code or building it in the Lambda console.
- Choose the required memory, timeout period and AWS IAM role.
- Specify the AWS resource that will trigger the function. Examples include a particular Amazon S3 bucket, an Amazon DynamoDB table or an Amazon Kinesis stream.
Lambda will run the function when the resource changes. Based on incoming requests, it will launch and manage the compute resources as required.
Developers can also use code compiler tools, such as Maven or Gradle, and packages to build functions.
Limitations: Soft and hard
AWS imposes several limitations or quotas, both soft and hard, that developers should be aware of before using Lambda's high-availability compute infrastructure. These limits pertain to the following:
- Execution time. Configurable maximum execution time limit of up to 15 minutes, beyond which AWS will forcefully stop the function.
- Concurrent executions. Number of parallel executions per region down from 1,000 to low double-digits.
- Memory and virtual CPU (vCPU) configuration. Up to 10 gigabytes (GB) of memory can be configured for a Lambda function. Memory size correlates with the vCPUs available to a Lambda function.
- Temporary storage. Capped at 75 GB for storing function code and the code of Lambda Layers.
- Elastic network interfaces (ENIs) per VPC. Up to 65,000 connections/ports for a Hyperplane ENI that can be reused by Lambda functions in the same subnet.
- Debugging capabilities. Hard-to-debug Lambda functions in real-world conditions, particularly if those functions are integrated with multiple other AWS services.
Users must also deal with the limits that AWS imposes around cold starts time, the size of Lambda functions -- specifically the unzipped code of these functions -- and the number of languages supported by Lambda.
The limits on concurrent executions, storage capacity for function and layer code, and ENIs are all soft limits. Quotas for maximum execution time, memory and compute constraints, storage restrictions, cold starts, function size limitations, supported languages, networking capabilities, and debugging functions are all hard limits.
Users can request AWS support to increase the soft limits. Hard limits cannot be increased; they can only be mitigated. For example, the 15-minute execution time limit and the 10 GB limit on configurable memory and vCPUs can both be mitigated by parallelizing workloads. Similarly, one way to mitigate Lambda's debugging limitations is to use self-service tools that allow debugging of Lambda functions on local machines.
Types of AWS Lambda services
AWS offers thousands of discrete services -- nearly 2,000 were released in 2018 alone. AWS uses the AWS Lambda console to help users monitor and manage their Lambda applications. The menu includes stacks that you launch in AWS CloudFormation by using the AWS CloudFormation console, the AWS Serverless Application Repository, the AWS command line interface, or the AWS Serverless Application Model CLI.
AWS Lambda use cases
As a serverless FaaS offering from a reliable cloud services provider, AWS Lambda can be used for many types of applications, including event-driven applications. With Lambda, organizations can run these applications during times of peak demand without crashing, overprovisioning resources or incurring significant costs.
AWS Lambda is also ideal for processing data quickly and at any scale. The service instantly scales out to more than 18k virtual central processing units, allowing teams to quickly and easily build all kinds of data processing workflows, interactive web experiences, and stable and scalable mobile or IoT backends.
AWS Lambda can be combined with other services in the AWS ecosystem and event triggers to build scalable web applications. These applications can be made to run in highly available configurations across multiple data centers.
Combining Lambda with other AWS serverless offerings and event triggers also enables developers to trigger Lambda data processing in real time with Amazon S3; to process real-time streaming data with Amazon Kinesis; to authenticate and process API requests with Amazon API Gateway; and to integrate with iOS, Android, Web, and React Native frontends with AWS Amplify, for example.
Lambda is also suitable for machine learning applications. Users can preprocess data before feeding it into the ML model. Lambda can also be combined with Amazon EFS to scale these applications up or down without worrying about infrastructure management or provisioning.
AWS Lambda can be used to perform data validation, filtering, sorting or other transformations for every data change in a DynamoDB table and load the transformed data to another data store. Because Amazon offers integration between DynamoDB -- Amazon's NoSQL database that uses JSON-based query language -- and AWS Lambda, developers can configure a Lambda function to be triggered whenever your DynamoDB table receives an update. In a Lambda function, you can do tasks such as sending notifications via Amazon Simple Notification Service, writing to other DynamoDB tables, managing Cognito identity pools, and performing a number of other functions both in and outside of AWS.
AWS Lambda and Amazon Kinesis can be used to process real-time streaming data for application activity tracking, transaction order processing, click stream analysis, data cleansing, metrics generation, log filtering, indexing, social media analysis, and IoT device data telemetry and metering.
AWS Lambda pricing
AWS Lambda is available on a pay-per-use basis. This means that users or organizations are charged based on the number of requests for each function in AWS Lambda and the time it takes for the code to execute, rounded up to the nearest 1 millisecond. If a function is never called, there is no cost.
The price for using Lambda also depends on the amount of memory selected by the user and allocated by AWS to a Lambda function. The amount of memory chosen also determines how much CPU power and other resources are allocated. If the memory size increases, the CPU available to the function also increases, along with the price. Users might also incur additional charges for utilizing other AWS services with AWS Lambda.
Users can reduce their Lambda bill by purchasing a one- or three-year Compute Savings Plan. This flexible pricing model offers low prices on many AWS services, including AWS Lambda, in exchange for a commitment to a consistent amount of usage measured in dollars per hour for the term of the plan.
AWS Lambda is available with a free tier of service that includes one million free requests, 400,000 gigabyte-seconds of compute time, and 100 gibibytes of HTTP response streaming per month. The free tier is ideal for users looking to get hands-on experience with AWS Lambda without incurring an upfront expense.
Current AWS Lambda uses by enterprises
Here are five examples of major enterprises using AWS Lambda:
- Capital One. Capital One Financial Corporation, an American bank holding company, has adopted AWS Lambda's serverless approach since it allows them to overcome the need to manage physical data centers and infrastructure as they pursue technological innovation and business efficiency. The company uses 1000s of Lambda functions that give their developers the freedom to focus on building valuable application logic for customers since AWS handles all other time-consuming, low-value tasks.
- Experian. Experian, an Ireland-based consumer credit reporting company, uses AWS Lambda's serverless, event-driven compute service to run code for different types of applications and backend services, while avoiding the need to provision or manage servers. Lambda also streamlines the assessment, audits, and remediations of Experian's cloud resources and enables the firm to simplify cloud management and operational troubleshooting.
- Broadridge Financial Solutions. Broadridge, a global Fintech firm, has developed a fully managed serverless architecture with AWS Lambda that simplifies document pre- and post-processing. Lambda brings greater automation into the document processing function for Broadridge, allowing the firm to deliver data faster, deeper insights, and more useful data points to customers.
- JP Morgan Chase. JPMC, an American multinational finance company, uses AWS Lambda for risk calculations. Along with other AWS services like Amazon Elastic Kubernetes Service and Amazon Elastic MapReduce, Lambda enables the firm to enhance its efficiency, security, and agility in the highly dynamic, tech-powered business landscape that JPMC operates in.
- Scania AB. Lambda allows Scania, a Sweden-basedprovider of transport solutions, to improve scalability and security and lower latency. With Lambda, the organization's developers can run code as needed without having to worry about clusters, provisioning, or server management.
How developers use AWS Lambda
Developers can list, delete, update and monitor functions through the Lambda dashboard, the CLI, or the SDK. The service also performs infrastructure-focused activities, such as server and operating system maintenance, patch deployment, and logging through AWS CloudWatch. Lambda also supports third-party logging APIs, and developers can connect custom APIs endpoints to Lambda through the Amazon API Gateway service.
Lambda Edge, part of Amazon CloudFront, enables developers to run Lambda code at edge locations that are geographically closer to end users around the world. This improves code and application performance as well as reduces latency. As with AWS Lambda, Lambda Edge also offers the benefit of zero server administration so developers don't have to provision or manage infrastructure and can instead focus on coding.
The Amazon CloudFront content delivery network generates events that trigger Lambda Edge to run code and deliver location-specific or customized content to end users. Lambda Edge runs code each time a function triggers, allowing it to scale according to the size of the workload.
Lambda Edge and CloudFront can be used for many different applications:
- HTTP request and response processing.
- Real-time image transformation.
- Website SEO.
- Mitigate or block intelligent bots at the edge.
- Build scalable web applications.
- balance the load on origins
- A/B testing on websites.
- Authentication and authorization for premium or paywalled website content.
- Real-time streaming data processing to track globally distributed user activity on websites and mobile applications.
AWS EC2 and AWS Lambda meet different needs in an AWS cloud environment. They can also work together, however. Check out our overview of Amazon EC2 vs. AWS Lambda. See how to create and deploy AWS Lambda functions with Terraform, learn how to speed up AWS Lambda cold starts with these strategies, and compare AWS Lambda vs. Azure Functions vs. Google Cloud Functions.