Skip to content

Add docs for stay open mode #84

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added .hugo_build.lock
Empty file.
1 change: 1 addition & 0 deletions content/en/localstack/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ This section covers configuration values that are specific to AWS services.
| | `docker` (default) | Run each function invocation in a separate Docker container. |
| | `local` (fallback) | Run Lambda functions in a temporary directory on the local machine. |
| | `docker-reuse` | Create one Docker container per function and reuse it across invocations. |
| `LAMBDA_STAY_OPEN_MODE` | `1` (default) | Usage of the [stay-open mode]({{< ref "lambda-executors#stay-open-mode" >}}) of Lambda containers. Only applicable if `LAMBDA_EXECUTOR=docker-reuse`. |
| `LAMBDA_REMOTE_DOCKER` | | determines whether Lambda code is copied or mounted into containers |
| | `true` (default) | your Lambda function definitions will be passed to the container by copying the zip file (potentially slower). It allows for remote execution, where the host and the client are not on the same machine.|
| | `false` | your Lambda function definitions will be passed to the container by mounting a volume (potentially faster). This requires to have the Docker client and the Docker host on the same machine. Also, `HOST_TMP_FOLDER` must be set properly, and a volume mount like `${HOST_TMP_FOLDER}:/tmp/localstack` needs to be configured if you're using docker-compose. |
Expand Down
21 changes: 20 additions & 1 deletion content/en/localstack/lambda-executors.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,29 @@ A typical invocation of a dummy python lambda can take around 3 seconds from sta
All supported lambda types can be used with this executor.


### Docker re-use
### Docker reuse

Configuration: `LAMBDA_EXECUTOR=docker-reuse`

#### Stay-open mode
LocalStack allows to use the stay-open mode of its lambda containers.
Copy link
Member

@whummer whummer Dec 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: We're usually writing Lambda with upper-case L, to make it clear that we're referring to the AWS service name (not critical at all, though..).

The containers stay open and wait for further invocations, without executing the initialization code of the lambda multiple times.
This results in way faster execution times, especially if the lambda has long-running initialization code.

The stay-open mode is the new default method when using `docker-reuse` as lambda executor, however, it has some restrictions:

* Only works if LocalStack runs in a Docker container
* Large Payloads (multiple MBs) do not work
* Problems with error handling in some runtimes

A list of failing tests with this mode can be found [in this GitHub issue](https://github.com/localstack/localstack/pull/5088).


#### Docker-exec execution mode
This mode is the default if LocalStack is started in host mode.
If you experience failures using the stay-open mode (either due to the mentioned restrictions or networking problems), you can force this mode by setting `LAMBDA_STAY_OPEN_MODE=0`.

This execution mode provides a balance between the speed of a local execution and the feature set and isolation of the `docker` executor.
While the initial call, which creates the container, will take roughly the same time of `docker` executor, the subsequent invocations will only take around 1 second (start to finish, invoked using the awscli), which roughly the time an actual aws invocation using this method takes.
The container is kept running 10 minutes after the last invocation for this lambda, then it will be destroyed (and recreated if necessary for the next invocation).
The complete lambda process is called using `docker-exec` each time of the invocation. While the invocation is still faster than `docker` execution mode, it is not as fast as with the stay-open mode (since the lambda has to be loaded and initialized every time).
2 changes: 1 addition & 1 deletion themes/docsy