Sharing Behaviour
In this lesson, you'll study the sharing behaviour of Lambda functions.
We'll cover the following...
As you start breaking down an application into Lambda functions, some of those functions will need to share behaviours. There are currently three options for that with Lambda functions:
- Common libraries
- Lambda layers
- Invoking one function from another
These options differ primarily in four aspects:
- Latency to execute shared code
- Runtime or deployment-time consistency
- Sharing across programming language runtimes
- Deployment speed and complexity
Bundling shared libraries #
The first option is to extract common code into a shared programming language library and bundle it with each function. This minimises the latency to execute shared code, since it’s just a quick in-memory call. Bundling dependencies with a function makes deployment simpler, but provides only deployment-time consistency. If you deploy just one function after changing the common code, all other functions will still run with the previous version. Common dependencies increase the package size for each function, so this is a good choice for typical programming language libraries, but may not be the best option for bundling a 100 MB native binary for a function that needs to redeploy frequently.
Shared libraries do ...