This article may rely excessively on sources
too closely associated with the subject, potentially preventing the article from being
verifiable and
neutral. (May 2024) |
Developer(s) | Amazon.com |
---|---|
Initial release | November 13, 2014 |
Operating system | Cross-platform |
Available in | English |
Website |
aws |
AWS Lambda is an event-driven, serverless Function as a Service (FaaS) provided by Amazon as a part of Amazon Web Services. It is designed to enable developers to run code without provisioning or managing servers. It executes code in response to events and automatically manages the computing resources required by that code. It was introduced on November 13, 2014. [1]
Note that in Lambda-based applications the line between the infrastructure and business logic is blurred and the apps are usually spread across various services. To get the most value from testing, a Lambda-based application should be tested mainly for its integrations; and unit tests should be used only if there is a complex business logic. [2] [3]
Following DevSecOps practices can help you to use and to secure Lambda-based applications more effectively. [4]
To make debugging and implementation of Lambda-based applications easier, developers are advised to use orchestration within the bounded context and to use choreography between the bounded-contexts. [2]
Each AWS Lambda instance is a container created from Amazon Linux AMIs (a Linux distribution related to RHEL) with 128–10240 MB of RAM (in 1 MB increments), [5] 512 MB to 10 GB of ephemeral storage in /tmp folder, [6] and a configurable execution time from 1 to 900 seconds. Ephemeral storage remains locally available only for the duration of the instance and is discarded after all tasks running on the instance are complete.
Since December 2020, Lambda has been capable of supporting Docker containers through ECR up to 10 GB in size. [7]
Node.js, Python, Java, Go, [8] Ruby, [9] and C# (through .NET) are all officially supported as of 2018 [update]. In late 2018, custom runtime support [10] was added to AWS Lambda.
AWS Lambda supports running native Linux executables by calling them from a supported runtime, such as Node.js. [11]
AWS Lambda was primarily designed for tasks such as handling image and object uploads to Amazon S3, updating DynamoDB tables, responding to website clicks and reacting to sensor readings from IoT connected devices. AWS Lambda can also be used to automatically provision back-end services triggered by custom HTTP requests, and "spin down" such services when not in use to save resources. These custom HTTP requests are configured in AWS API Gateway, which can also handle authentication and authorization in conjunction with AWS Cognito.
Unlike Amazon EC2, which is billed by the second (with a minimum of 60 seconds), AWS Lambda is billed by the millisecond with no minimum.
AWS Lambda functions are often used in association with AWS SQS queues to process asynchronous tasks in distributed architectures.
In 2019, at the AWS annual cloud computing conference (AWS re:Invent), the AWS Lambda team announced "Provisioned Concurrency", a feature that "keeps functions initialized and hyper-ready to respond in double-digit milliseconds." [12] The Lambda team described Provisioned Concurrency as "ideal for implementing interactive services, such as web and mobile backends, latency-sensitive microservices, or synchronous APIs." [13]
The Lambda Function URL gives Lambda a unique and permanent URL which can be accessed by authenticated and non-authenticated users alike. [14] It was launched in April 6, 2022 by the AWS Lambda team. [15]
A typical function URL has the following format: [14]
https://<url-id>.lambda-url.<region>.on.aws
Before Function URLs, Lambda functions could be invoked only using AWS Lambda APIs or Amazon API Gateway. [16] Response streaming was also made possible with function URLs. [17]
There are no extra charges included with invoking a Function URL, other than the duration and requests. [18] Function URLs are included in Lambda’s request and duration pricing. [19]
If a Lambda function URL is made publicly available with AuthType = NONE, it will warrant unauthenticated access to the Lambda function. [20] It can lead to a DDoS attack, which will incur costs to the AWS account which is hosting the Lambda function.
AWS Lambda Layers allow developers to easily manage and share common components across multiple Lambda functions. It's designed to promote code reusability and simplify the deployment of libraries, custom runtimes, and other dependencies that Lambda functions might need. Lambda Layers can be particularly useful in microservices architectures, where multiple functions might share the same dependencies. [21] By using layers, one can ensure that all functions are using the same version of a library, making the application more consistent and easier to manage.
A Lambda Layer is a .zip file archive that allows to package and deploy common components separately from a Lambda function code. [22] A single AWS Lambda function can include up to five layers at a time. The layers are applied in a specified order, allowing later layers to override the content of earlier ones if there are conflicts. [23] This layering system can significantly reduce the size of Lambda deployment packages, as there is no need to include these common components in every function's deployment package.
Create a Lambda Layer: One first creates a layer by packaging libraries or other dependencies into a .zip file and then uploading it to Lambda. [24] The runtimes that the layer is compatible with can be specified when creating a layer. [25]
Add the Layer to Lambda Functions: When creating or updating a Lambda function, the layers to be included in the function can be specified. The Lambda service will then merge function code with the specified layers to create the execution environment. [26]
Versioning: Each time a new version of a layer is published, it receives a unique version number. [27] This is useful for managing updates to layers separately from function code. It also ensures that functions can continue using older versions of a layer if needed.
Sharing Layers: Layers can be shared across different AWS accounts or made public to the broader AWS community. [28] This is particularly useful for commonly used libraries or runtime extensions.