Lambda Execution Context

  • Similar for multiple AWS Lambda function to share the same context so that they can reuse to save time
  • Execution context includes /tmp folder
    • If your lambda function needs to download a big file or need some disk space to perform operations
    • Max size is 512 MB
    • For permanent persistent object, use S3
  • Good for database connection, http clients, sdk clients (things that you can re-use)

Example

Do not intialise database connection like this
Pasted image 20221011111819.png
Everytime that lambda execute your function, it tries to connect to the database again.

Instead do this

Pasted image 20221011111906.png
Let the execution context handling all the uplifting for you.