Issue
I am looking at AWS Lambda to create a Python function that would process data. I need to load a heavy model to run my script (trained word2vec model), it takes about 5 min to do it on my computer for example, but once it's loaded, the execution of the function is very fast. If I use AWS Lambda, will this model load only once or will it load each time I call my function?
Solution
Maybe.
AWS Lambda uses reusable containers. So, for your use case, the Lambda function will execute quickly if it happened in an already initialized container. It'll be slow otherwise. However, there is no way you can predict the behavior.
Relevant documentation:
- From here:
The first time a function executes after being created or having its code or resource configuration updated, a new container with the appropriate resources will be created to execute it, and the code for the function will be loaded into the container.
Let’s say your function finishes, and some time passes, then you call it again. Lambda may create a new container all over again, in which case the experience is just as described above. This will be the case for certain if you change your code. However, if you haven’t changed the code and not too much time has gone by, Lambda may reuse the previous container.
Remember, you can’t depend on a container being reused, since it’s Lambda’s prerogative to create a new one instead.
- More official documentation here.
Answered By - ketan vijayvargiya
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.