The technology behind Lambda is actually container-based, which means it isolates a function from other instances. The container's sandbox provides resources specific to each configuration for them.
A Lambda function can be terminated in a number of ways:
- Timeout: As previously mentioned, when the 5-minute limitation is reached, the current execution of the function will be stopped no matter what it is doing.
- Controlled termination: If the function provides a callback and the callback is executed to invoke the context.done() method, the function will be terminated, no matter what it is doing.
- Default termination: The function ends and terminates normally. Also, there is no callback to invoke the context.done() method. This case will be considered as the default termination.
- Function crashes or process.exit() is called: If the function panics or generates segmentation faults, the function will terminate and therefore the container is stopped.