Replies: 1 comment 8 replies
-
|
I made a trial also, using the nodejs14x runtime: https://github.com/viesti/nbb-lambda The gist was to load nbb inside the handler function, since the async import that nbb uses seems to make it hard to load the libraty in a "top level" expression in nodejs, in the way that the default Lambda runtime works (seems that it looks for index.js, so misses index.mjs). I used the Lambda console to then modify the core.cljs code so that it loades the bundled AWS JavaScript library and used functionality from that library. Next thing wouöd be to test the v3 of AWS JS libs, since the nodejs runtimes bundle only v2. |
Beta Was this translation helpful? Give feedback.
8 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
nbb on AWS Lambda
I wanted to play with idea of having a simple and easy way to run
cljscode on AWS Lambda. Ideally the goal is that it would be possible to writecljscode directly in the Lambda console and run it. Another goal is to use existing battle tested runtime code from AWS as much as possible.Approach
nbbvianpmcljsfile withnbbAPIFiles
Dockerfile
runtime/bootstrap
This file is originally copied from
/var/runtime/bootstrap.The only change is that
/var/runtime/index.jsfile extension was changed to.mjsso we can importnbb.runtime/index.mjs
This file is originally copied from
/var/runtime/index.js. Since the original code usesrequire(cjs) andnbbusesimport(mjs) I made a quick hack to support both (createRequire).Instead of using
UserFunction.loadto load userland code and resolve the handler function, I useloadFilefrom nbb API to do the same. Here the file and function names are hardcoded but they could easily be resolved fromLAMBDA_TASK_ROOTand_HANDLERenv vars.test.cljs
Build and deploy
I built the Docker image locally and pushed it to a private
ecrcontainer repository on my personal AWS account. Then I created a new lambda function from the console and told lambda to use the image from the repo.Benchmarks
NOTE benchmarks are naive and meant to just provide a "ballpark"
Benchmarks were made from the AWS Console by clicking the "test" button.
NodeJS 14 x86 AWS Default (baseline)
Cold start
2nd run
3rd run
Several subsequent runs
NodeJS 14 x86 Docker nbb as lib, code loaded on init
Cold start
2nd run
3rd run
Several subsequent runs
Conclusion
Next steps
nreplserver locally?cljscode with thenbbexecutableBeta Was this translation helpful? Give feedback.
All reactions