2

I understand that using AWS Lambda allows us to submit single functions to a runtime and have them execute when needed. But what about the software these functions depend on? Where do these get installed? Does the installation and configuration happen every time the lambda instance gets spun up? Wouldn't this take a while for larger applications/detailed configurations?

Or does the installed software sit on the server (say on an EC2 instance) and then simply gets called upon as needed by the lambda functions?

Cybernetic
  • 12,628
  • 16
  • 93
  • 132

1 Answers1

2

There are essentially two ways to manage dependencies of a Lambda function.

  1. Using lambda layers: A Lambda layer is an archive containing additional code, such as libraries, dependencies, or even custom runtimes. When you include a layer in a function, the contents are extracted to the /opt directory in the execution environment. You can include up to five layers per function, which count towards the standard Lambda deployment size limits. Have a look at this article for more details.

  2. Using container images: You can package your code and dependencies as a container image using tools such as the Docker command line interface (CLI). You can then upload the image to your container registry hosted on Amazon Elastic Container Registry (Amazon ECR). See the official docs here.

Because Lambda can scale to zero, it suffers from a so-called cold star issues. This means that unless there is a warm, running container instance available, Lambda has to "cold start" a new container causing some delay, especially for large footprint applications stacks such as JVM based.

Best, Stefan

StefanN
  • 527
  • 1
  • 4
  • 12