-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Lambda lazy load #2278
Closed
Closed
Lambda lazy load #2278
Conversation
This file contains 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
This specific port per integration is pretty brittle to begin with, but it does work. Currently, the fact that it works is facilitated by the fact that most people don't use 5555 (Hapi) and 6666 (Express) for anything. That said, the ever-popular Gatsby uses 8888 by default, so let's use 9999!
Without this fix to `package-lock.json`, which it's not immediately clear to me what was wrong (possibly a transitive error) there were type errors manifesting on the `master` branch.
I've added these on Mac, and I believe that Mac will no longer _remove_ them after [email protected], so hopefully fix some `package-lock.json` flapping!
When debugging the fix in b84770c, I removed the `package-lock.json`, ran `npm install`, then individually reviewed the fixes to better understand what happened. I noted a few other differences in the `package-lock.json`, mostly due to changes in `fsevents` (which internally switched to `bundledDependencies`), and changes in `@apollographql/apollo-tools`. I've reviewed these as well, and they all look reasonable, but wanted to put them in a different commit for later bisecting purposes (hopefully a purpose I won't have!).
There was a breaking change to `core-js` in `3.0.0-beta.12` which seems to warrant this extra protection.
The purpose of this PR is to remove the `apollo-graphql` package from this repository, to be added to `apollo-tooling` instead. https://github.com/apollographql/apollo-tooling Ref: apollographql/apollo-tooling#1018
This will allow Lerna to release the first version as `[email protected]`.
- [email protected] - [email protected] - [email protected] - [email protected] - [email protected] - [email protected] - [email protected] - [email protected] - [email protected] - [email protected] - [email protected] - [email protected] - [email protected] - [email protected] - [email protected] - [email protected] - [email protected] - [email protected] - [email protected] - [email protected] - [email protected] - [email protected] - [email protected] - [email protected]
Re-land: Fastify integration from #1971.
- [email protected] - [email protected] - [email protected] - [email protected] - [email protected] - [email protected] - [email protected] - [email protected] - [email protected] - [email protected] - [email protected] - [email protected] - [email protected] - [email protected] - [email protected] - [email protected] - [email protected] - [email protected] - [email protected] - [email protected] - [email protected] - [email protected] - [email protected] - [email protected]
hacky lambda process.env fix" fix linting issues update changelog fix polyfill check use AWS_EXECUTION_ENV fix styling fix version check Update CHANGELOG.md
…nto lambda_lazy_load
I screwed up a rebease and cant seem to unscrew it, so I am closing this and opening #2324 |
4 tasks
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
TODO:
This is to address loading time issues raised in #2162
There are three changes of note.
lambda-server-core
I moved thesubscriptions-transport-ws
andapollo-engine-reporting
into lazy-loadedrequires
and changed the top-level imports to just import the type. Since lambda's cannot take advantage of these packages, loading them is pure cost. I didn't see any other type-only imports to style after, so I followed the handbook convention of underscore-prefix-capitalized.util.promisify
polyfill check the node version before loading itself. NOTE: there are already tests in node 6 and node 8 that exercise this coderuntimeSupportsUploads()
that looks forAWS_EXECUTION_ENV
, which the lambda runtime sets. This checks stop the import ofapollo-upload
from occuring. The library is unfortunately a top-level import, so moving it anywhere thatapollo-server-lambda
could have controlled directly without changing the contract was impossible. A better solution probably exists that does not hack its way throughprocess.env
. The best solution would be removingapollo-upload
from the core entirely, since it surely does not belong there.These changes combine to reduce the cold-start time of a 512mb AWS Lambda from ~450ms to ~250ms.
Before
After
(Yes, the flame graph has a rendering bug, but the numbers are accurate)
512 is a pretty beefy lambda for node, 256 is more common. These effect will be amplified the lower memory you go, because AWS matches the CPU to the allocated memory. If it is necessary, I can re-run these performance profiling on smaller lambdas.