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

Skip to content

Lambda performance is poor without docker-reuse flag #4013

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
noahskelton opened this issue May 13, 2021 · 6 comments
Closed

Lambda performance is poor without docker-reuse flag #4013

noahskelton opened this issue May 13, 2021 · 6 comments
Labels
area: docker Use Docker with LocalStack aws:lambda AWS Lambda

Comments

@noahskelton
Copy link

Type of request: This is a ...

[ ] bug report
[x] feature request

Detailed description

I was experiencing very high CPU usage when invoking an API gateway lambda in fairly frequent succession - this was resolved by using the LAMBDA_EXECUTOR=docker-reuse flag in the docker-compose configuration, allowing the container to be reused after the first lambda invocation.

  • Is there a reason why docker is the default rather than docker-reuse for the LAMBDA_EXECUTOR flag?
  • I think there should be a note under the Troubleshooting section in the docs about this for Lambda performance - the tmp directory is mentioned, but that didn't solve performance issues for me. Happy to contribute a PR if you think this is appropriate.

Expected behavior

Actual behavior

Steps to reproduce

Command used to start LocalStack

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

@jleck
Copy link

jleck commented May 13, 2021

@calmoo I'm having some issues with lambda performance even with docker-reuse (~12 seconds cold start, ~8 seconds once warm). What sort of response times do you see with docker-reuse?

@noahskelton
Copy link
Author

@jleck After first invocation, I got the response time down from ~10-12 seconds to under 1 second.

@jleck
Copy link

jleck commented May 14, 2021

Might be something my end that's slowing it down still then after the first. Thanks!

@ThomasLabstep
Copy link

@calmoo What's your setup to achieve <1s ?

See my issue with my setup: #4042

@tobias-zeptio
Copy link

I'm doing some extensive testing on our services using localstack, and the slowness is kinda annoying. Can someone explain why a lambda should even take 1s (which is what I'm seeing) with docker-reuse. In AWS we get milliseconds. Isn't it just a method call to the handler function? Is the container reinitialized for each invoke?

@dominikschubert dominikschubert added aws:lambda AWS Lambda area: docker Use Docker with LocalStack lambda-execution labels Oct 18, 2021
@whummer
Copy link
Member

whummer commented Dec 14, 2021

Thanks for reporting @tobias-zeptio @ThomasLabstep @jleck @noahskelton . We have recently introduced "stay-open" mode which further improves the Lambda execution times, and is now the default for the docker-reuse Lambda executor (see PR #4914). Can you confirm that the execution times have improved in recent versions, or are you still experiencing these performance issues?

From a compatibility perspective we're currently still leaning towards having docker as the default executor, as this is the "zero-assumption" mode that works out of the box (without opening any separate network ports, allowing multiple invocations in parallel, etc). We'll make sure to add a note to the troubleshooting section of our documentation (our README/docs are currently being refactored, but we'll take it into account πŸ‘ /cc @HarshCasper ). Thanks!

@whummer whummer closed this as completed Dec 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: docker Use Docker with LocalStack aws:lambda AWS Lambda
Projects
None yet
Development

No branches or pull requests

6 participants