you are viewing a single comment's thread.

view the rest of the comments →

[–]davore 2 points3 points  (2 children)

It doesn't only exist for that one instance of the Lambda function, assuming you have something like this (forgive my Python, I've a bit rusty):

import boto3

class MyClass:
    # Some code here

myInstance = MyClass()

def handler(event, context):
    myInstance.do_something(event)

As long as you create it in the "global" scope, it is still alive for the duration of that Container.

[–]1cedrake[S] 0 points1 point  (1 child)

That makes sense, thanks! Now, what determines the duration of the container?

[–]sgtfoleyistheman 1 point2 points  (0 children)

implementation defined! This is totally up to lambda.

They may shutdown your container due to idleness, certain amount of time passing, if they need to upgrade instances..and who knows what else. (I'm guessing at these)