Skip to content
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

slow local invoke compared to direct lambda invocation #341

Closed
peteruhnak opened this issue Mar 29, 2018 · 2 comments
Closed

slow local invoke compared to direct lambda invocation #341

peteruhnak opened this issue Mar 29, 2018 · 2 comments

Comments

@peteruhnak
Copy link

I'm running into a strange slowdown when locally invoking a lambda function.

Step pulling the docker image always takes around 30 seconds. There's barely any network traffic, so it is not actually downloading it. Maybe a timeout, or it is always computing the checksum? (The same slowdown is present when I do docker pull lambci/lambda

$ time sam local invoke HelloWorld -e event.json
2018/03/29 12:55:26 Successfully parsed template.yaml
�[34mINFO�[0m[0000] Unable to use system certificate pool: crypto/x509: system root pool is not available on Windows
2018/03/29 12:55:26 Connected to Docker 1.37
�[34mINFO�[0m[0000] Unable to use system certificate pool: crypto/x509: system root pool is not available on Windows
2018/03/29 12:55:26 Fetching lambci/lambda:nodejs6.10 image for nodejs6.10 runtime...
nodejs6.10: Pulling from lambci/lambda
Digest: sha256:bc47c223a2accf47c51adc6e1949bda9b557764be38a76ebac73e545044079cc
Status: Image is up to date for lambci/lambda:nodejs6.10
2018/03/29 12:55:58 Invoking index.handler (nodejs6.10)
2018/03/29 12:55:58 Mounting /d/prog/sam-node-hello-world as /var/task:ro inside runtime container
�[32mSTART RequestId: 9556341d-a069-139c-cef9-eb19b1ea1c41 Version: $LATEST�[0m
�[34m2018-03-29T10:56:00.433Z   9556341d-a069-139c-cef9-eb19b1ea1c41    �[0mLOG: Name is Bob
�[32mEND RequestId: 9556341d-a069-139c-cef9-eb19b1ea1c41�[0m
�[32mREPORT RequestId: 9556341d-a069-139c-cef9-eb19b1ea1c41     Duration: 6.09 ms       Billed Duration: 100 ms Memory Size: 128 MB     Max Memory Used: 28 MB  �[0m

"Hello Bob"

real    0m33.644s
user    0m0.000s
sys     0m0.000s

I would expect performance similar to invoking it directly.

$ time docker run -v "$PWD":/var/task lambci/lambda index.handler '{"name" : "Bob"}'
START RequestId: d14605bd-2f8e-1aad-0b06-ea972b2ff0a3 Version: $LATEST
2018-03-29T11:08:29.563Z        d14605bd-2f8e-1aad-0b06-ea972b2ff0a3    LOG: Name is Bob
END RequestId: d14605bd-2f8e-1aad-0b06-ea972b2ff0a3
REPORT RequestId: d14605bd-2f8e-1aad-0b06-ea972b2ff0a3  Duration: 6.03 ms       Billed Duration: 100 ms Memory Size: 1536 MB    Max Memory Used: 23 MB

"Hello Bob"

real    0m0.883s
user    0m0.015s
sys     0m0.000s
@n3ziniuka5
Copy link

If you experience the same slowdown by just doing docker pull lambci/lambda then something is wrong with docker, not sam-local. You should look or ask for a solution elsewhere.

In the meantime, you can try sam local invoke --skip-pull-image=true HelloWorld -e event.json

@jfuss
Copy link
Contributor

jfuss commented May 10, 2018

This seems to be answered by @n3ziniuka5. Closing

@jfuss jfuss closed this as completed May 10, 2018
qingchm pushed a commit to qingchm/aws-sam-cli that referenced this issue Sep 17, 2021
* logs command improvements

* update help text and move imports into method

* throttling checks, generating new session and client for every coroutine, use boto StackResource object instead of creating our own

* remove mypy boto stubs usage, raise exception other than throttling, use common static var for lambda name

* make black & pylint happy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants