Skip to content
This repository was archived by the owner on Dec 15, 2021. It is now read-only.

require() deployed nodejs function instead of executing inline#789

Merged
andresmgot merged 4 commits intovmware-archive:masterfrom
usefulio:feature/nodejs/supportWebpack
Sep 18, 2018
Merged

require() deployed nodejs function instead of executing inline#789
andresmgot merged 4 commits intovmware-archive:masterfrom
usefulio:feature/nodejs/supportWebpack

Conversation

@ianserlin
Copy link
Contributor

Issue Ref: #779

Description:

A simple change to how the user's code is run in kubeless.js allows webpacked functions to work out of the box and requires no changes to the way existing non-webpacked functions are written or deployed.

Note that this change means the user's function code is require()-d from disk on each run instead of being read as a string into memory once on pod startup.

However, this has a negligible effect on performance for the following reasons:

  1. Most real-world functions are non-trivial and will have dependencies.
  2. Some significant percentage of the time, webpacking all the dependencies into a single js file (which could be read into memory) will result in a payload size greater than 1mb, which is Kubeless' function size limit.
  3. Those real-world functions will have to take advantage of Kubeless' dependency installation support on deployment.

That means that the size of code loaded as dependencies from disk will typically far outweigh the size of the function itself, making this one additional load from disk negligible as long as this package management solution is used.

Hope that makes sense.

TODOs:

  • Ready to review
  • Automated Tests: existing tests pass, no new tests needed
  • Docs: no new docs needed, it will just work with webpacked functions from now on

@andresmgot
Copy link
Contributor

Thanks for the PR @ianserlin. It looks good to me but can you add a small section in the runtimes.md file, in the NodeJS section, to explain how to use functions "webpacked"?

@ianserlin
Copy link
Contributor Author

@andresmgot Roger that, added instructions and sample to the runtimes.md docs.

@andresmgot
Copy link
Contributor

Thank you for updating the docs. One more thing, can you build and push (to your own repo) the nodejs images and change the reference at kubeless-non-rbac.jsonnet? That way CircleCI will test the changes. I will push them to the kubeless repo afterwards.

@SomeoneWeird
Copy link
Contributor

This would be useful for us as well, do we just need CircleCI to go green before we can land this?

@andresmgot
Copy link
Contributor

yes, we need to build the image and change the kubeless-non-rbac.jsonnet to test the changes. We also need to fix the conflict with the docs.

@bbeesley
Copy link

Any chance of getting this progressed? Being unable to run webpacked code is severely limiting the usefulness of the nodejs support here.

@andresmgot
Copy link
Contributor

cc/ @ianserlin are you able to continue with this?

@ianserlin
Copy link
Contributor Author

Yes, I can work on the requested changes this week. We've already gone to production with this setup.

@richardPFisk
Copy link

This is very useful addition. And, the accompanying explanation is useful too. Keep going 👍

@andresmgot andresmgot merged commit 2581ccb into vmware-archive:master Sep 18, 2018
@andresmgot
Copy link
Contributor

Landing this since it has been rebased. Thank you all for the input and sorry for the slow response!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants