-
Notifications
You must be signed in to change notification settings - Fork 363
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
Importing task decorator from zappa.asynchronous takes ~2.5s #1345
Comments
I am able to reproduce your issue on Windows, @texonidas , if I disable my AWS security setup (no profile or explicit keys). To see what is happening, extend your example. import logging
logging.basicConfig(level=logging.DEBUG)
from zappa.asynchronous import task The async task decorator import triggers an immediate AWS API connection to the Lambda service to keep the async resources warm and available: Lines 108 to 112 in 055db2e
Your Windows machine is trying to get credentials to connect to AWS during the import. Source: https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html#configuring-credentials At the end of the list of credential sources, is an attempt to make an HTTP connection to the instance metadata service. This service probably won't exist on your Windows computer. The boto3 library tries, waits, and eventually times out, for your total observed time of about 2 seconds.
I believe this is an AWS credential setup issue on your workstation, because of how the boto3 library works. I don't believe this is a Zappa-specific issue, because this will only happen on your local laptop if you don't have your AWS credentials configured. This won't happen in the Lambda service because credentials are always available. To resolve this issue, the easiest way is to configure your AWS access per the instructions at boto3, https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html#configuring-credentials Another great source is directly from the Zappa README.md: Before you begin, make sure ... your AWS credentials file is properly installed. |
As above, simply importing the task decorator adds >2 seconds(!!!) to application start time.
Context
This is not a bug per se, but given the (ideally) snappy nature of lambda, a simple import from Zappa should not be adding this much overhead.
Expected Behavior
Quick
Actual Behavior
Slow
Possible Fix
Not a clue, however the reproduction below seems to indicate sockets are to blame.
Steps to Reproduce
import_zappa.py
, containingfrom zappa.asynchronous import task
python -m cProfile -s tottime import_zappa.py > output.log
Truncated output:
Your Environment
pip freeze
:The text was updated successfully, but these errors were encountered: