Are lambda extensions shared across multiple instances of a lambda?

I'm trying to improve the cold start performance of a lambda. One of the things that takes time at startup is fetching information from the secrets manager.

I've found a few solutions that talk about caching information from secrets manager using lambda extensions.

  1. https://docs.aws.amazon.com/prescriptive-guidance/latest/patterns/cache-secrets-using-aws-lambda-extensions.html
  2. https://github.com/square/lambda-secrets-prefetch
  3. https://github.com/hariohmprasath/aws-lambda-extensions

If you cached a request from secrets manager, using the lambda extension approach, is it cached only for that instance of the lambda or is it cached for all instances of the lambda?

If it's cached for all instances then in theory it would help me reduce cold start times.


Unfortunately, it is cached only for that instance of the lambda.

Extensions are running inside the same container with the lambda. Therefore, they will not share memory between different instances of the lambda. More specifically, every time that a lambda has a cold start - a fresh process of the extensions is being executed.

Disclaimer: I just published a post explaining more about extensions: https://aws.amazon.com/blogs/apn/zero-friction-aws-lambda-instrumentation-a-practical-guide-to-extensions/ I believe that it will help you understand more about that power of extensions, and how it can help you in other ways.