[Serverless] Lazy-load datadog/api to speed up the cold start#684
Closed
maxday wants to merge 3 commits into
Closed
[Serverless] Lazy-load datadog/api to speed up the cold start#684maxday wants to merge 3 commits into
maxday wants to merge 3 commits into
Conversation
maxday
commented
Aug 27, 2021
|
|
||
| # If we are in an AWS Lambda environment we can skip loading and configuration api | ||
| # as underlying packages are heavy to load and slows down cold start | ||
| if os.environ.get("AWS_LAMBDA_FUNCTION_NAME") is None: |
Author
There was a problem hiding this comment.
I was thinking about a double check with the presence of /opt/datadog-agent But this file is only loaded when the extension is here (https://github.com/DataDog/datadog-lambda-python/blob/main/datadog_lambda/metric.py#L22)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
This PR lazy-loads the
datadog/apipackage.This package is quite heavy (mainly due to http_client) and slows down cold starts in AWS Lambda environment.
Here is the flamegraph showing the size of datadog/api (in purple)
We have already refactored our datadog/api in the Lambda Library here : DataDog/datadog-lambda-python#163
Description of the Change
Lazy-load the datadog/api package + unit testing
Alternate Designs
As we use this package in datadog-lambda-python the change needs to be at this deeper level
Verification Process
New flamegraph does NOT show any calls to
datadog/apiReview checklist (to be filled by reviewers)
changelog/label attached. If applicable it should have thebackward-incompatiblelabel attached.do-not-merge/label attached.kind/andseverity/labels attached at least.