Thanks to visit codestin.com
Credit goes to github.com

Skip to content

on MacOS, mounting /tmp/localstack makes lambdas slow #2515

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

Closed
yonahforst opened this issue Jun 5, 2020 · 6 comments
Closed

on MacOS, mounting /tmp/localstack makes lambdas slow #2515

yonahforst opened this issue Jun 5, 2020 · 6 comments
Labels
area: documentation Issues related to LocalStack documentation type: usage Usage of LocalStack and Best Practices

Comments

@yonahforst
Copy link
Contributor

yonahforst commented Jun 5, 2020

Type of request: This is a ...

[x] bug report
[ ] feature request

Detailed description

When running localstack on MacOS using the example docker-compose.yml, Lambda functions can take a long time to start up.

I think this is because of existing performance issues with osxfs, the file system server in Docker for Mac.

If your using LAMBDA_EXECUTOR=docker, the copying of zipped code to new lambci/lambda containers can take a very long time.

If you're using serverless-localstack, enabling mountCode solves the slow copying, but then actually requiring your code inside the lambda function can take a long time (mostly because of node_modules).

To solve this, I disabled mounting /tmp/localstack in my docker-compose.yml

    volumes:
      # - "${TMPDIR:-/tmp/localstack}:/tmp/localstack"
      - "/var/run/docker.sock:/var/run/docker.sock"

...

Expected behavior

...

Actual behavior

...

Steps to reproduce

Command used to start LocalStack

...

Client code (AWS SDK code snippet, or sequence of "awslocal" commands)

...

@whummer
Copy link
Member

whummer commented Jun 6, 2020

Thanks for reporting @yonahforst . Not sure if this is a bug per se, but performance can indeed become a bit slow if you're using large Lambda archives in the mounted tmp folder under MacOS. Would you mind creating a pull request with a small note in the README that describes your fix (perhaps in the Troubleshooting section)? Apart from the documentation change, is there anything else you think we can/should do here? Thanks

@whummer whummer added area: documentation Issues related to LocalStack documentation pr-requested type: usage Usage of LocalStack and Best Practices labels Jun 6, 2020
@whummer
Copy link
Member

whummer commented Jun 20, 2020

Thanks again. A short note on performance and Lambda mounting has now been added to the Troubleshooting part of the README: https://github.com/localstack/localstack#troubleshooting

@jgonera
Copy link

jgonera commented Apr 22, 2022

Thanks again. A short note on performance and Lambda mounting has now been added to the Troubleshooting part of the README: https://github.com/localstack/localstack#troubleshooting

This is a dead link. Does this documentation live somewhere else now?

@jgonera
Copy link

jgonera commented May 12, 2022

@whummer Is there any place where I can find this explained in the official docs?

@whummer
Copy link
Member

whummer commented May 12, 2022

Hi @jgonera , we have restructured our docs in the meantime - the best way to get started with Lambda code mounting (hot swapping) is to follow our docs here: https://docs.localstack.cloud/tools/lambda-tools/hot-swapping/#code-hot-swapping-for-python-lambdas

Please keep us posted on how it goes - happy to provide more guidance if you have more specific questions regarding Lambda performance and/or code mounting.. 👍 Thanks

@jgonera
Copy link

jgonera commented May 22, 2022

@whummer That was useful but I'm still not sure why we need the - "${TMPDIR:-/tmp/localstack}:/tmp/localstack" mount. It still makes things slower because things like unzipping lambdas use the slow macOS volume mounts instead of using container's native file system. Do I need this mount for anything if I don't use persistence?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: documentation Issues related to LocalStack documentation type: usage Usage of LocalStack and Best Practices
Projects
None yet
Development

No branches or pull requests

3 participants