Reputation: 972
We have created an AWS Lambda function in Python through the console, and tested by clicking the "Test" button. It works fine.
So now I'd like to understand, every time when I hit "Test",
If not, what if I create a sub-process within the handler function, how to get hold of the running sub-process between multiple invocations of this Lambda function?
Appreciate for the clarification!
Upvotes: 0
Views: 922
Reputation: 261
An AWS Lambda function has a chance that it will rerun the same container on the same machine, it can even restart a process that was running in the container when Lambda stopped running the container. The important thing to remember when designing your Lambda function is that this is not guaranteed. You have to write your Lambda function so that it can handle subsequent executions being done on a clean environment on a different machine.
Please remember that AWS Lambda Functions will be stopped after 15 minutes of run time. Please see: https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-limits.html
You could try designing your Lambda so that it does some processing, then stores the data elsewhere, then the next Lambda function that launches will perform some more processing as soon as the previous Lambda finishes. You usually want to use Lambda for workloads that wait for a certain event or time before performing more processing.
One of the best use cases for using Lambda is only paying for processing power when you need it.
For your use case you might want to consider using some other container service like:
EKS - https://aws.amazon.com/eks/ or ECS - https://aws.amazon.com/ecs/
Or possibly even consider Elastic Beanstalk - https://aws.amazon.com/elasticbeanstalk/
Upvotes: 2