Previous: Kinesis, Next: Route53Up: Cloud

Lambda

Table of Contents

1 Links

2 Intro

The main method of triggering Lambdas is to use an event source mapping which typically reads an item from a stream or queue and then uses this item to invoke a Lambda using the appropriate event type.

3 Runtimes

Lambdas run in execution environments which provide an isolated environment for Lambda functions to run. Runtimes provide support for a specific language within an execution environment. If the frequency of events is more than a single instance can handle, AWS Lambda will scale by starting more instances, and will stop instances that are no longer active.

4 Lifecycle

When using a provisioned runtime (e.g. you've created a class using an AWS SDK), AWS Lambda will instantiate the class and re-use it for multiple events so resources (e.g. an S3 client) can be re used on subsequent invocations.

You can use reserved concurrency (ReservedConcurrentExecutions) to guarentee the maximum number of concurrent instances of the function. Setting this to zero will stop any events being processed. Alternatively, you can use provisioned concurrency to initialize a requested number of environments prior to any invocations.

5 Layers

You can use Lambda Layers to re-use particular parts of your environment. A layer basically consists of a zip file containing files grouped into one or more directories who themselves have special meaning. For example, if you are using the java runtime, then CLASSPATH is always set to java/lib and so you can add to the classpath if you use a layer like:

my-layer.zip
└ java/lib/my-dep.jar

Similarly, all runtimes have bin/ in their PATH and so executables can be added to a Lambda runtime this way.

Author: root

Created: 2024-03-23 Sat 11:44

Validate