awslabs / llrt

LLRT (Low Latency Runtime) is an experimental, lightweight JavaScript runtime designed to address the growing demand for fast and efficient Serverless applications.
Apache License 2.0
7.76k stars 342 forks source link

Issue using this with raw JS and no build step #288

Closed LewisCowlesMotive closed 3 months ago

LewisCowlesMotive commented 3 months ago

It would be really great to get an example of using this using raw JS with no esbuild step. My code works in Node 20, but fails if attempting to use this layer on the 2023 image that has no language runtime, even with the arm64 code added as a layer.

arn arn:aws:lambda:us-east-1:667977005188:function:sandbox-pnc-gateway-nodejs

Just trying to see if NodeJS can operate even close to where Python 3.11 image is operating

richarddavison commented 3 months ago

Hi @LewisCowlesMotive. I'm not following, are you trying to use sandbox-pnc-gateway-nodejs layer and run with LLRT?

LewisCowlesMotive commented 3 months ago

Hi Richard, Not quite, although it does run under nodeJS. If I switch the runtime to the 2023 amazon that does not have nodeJS, and have used the arm64 zip (it's an arm64 lambda) nodejs code doesn't "just run"; so I'm wondering if there might be lower-level steps to use this with say a hello-world or one of the standard AWS examples that talk to dynamoDB, or other network services.

The key thing is. Given some JS that works. Without esbuild or typescript. What does someone need to do, to test if this has any performance impact at all?

richarddavison commented 3 months ago

Hi Richard, Not quite, although it does run under nodeJS. If I switch the runtime to the 2023 amazon that does not have nodeJS, and have used the arm64 zip (it's an arm64 lambda) nodejs code doesn't "just run"; so I'm wondering if there might be lower-level steps to use this with say a hello-world or one of the standard AWS examples that talk to dynamoDB, or other network services.

The key thing is. Given some JS that works. Without esbuild or typescript. What does someone need to do, to test if this has any performance impact at all?

Ah I see. I would recommend to checkout our SAM examples. That should give you a pretty good idea what to do. In summary:

  1. Download LLRT for your target platform llrt-lambda-arm64.zip
  2. Add your source code together with the bootstrap file from the zip above.
  3. Upload both and use Amazon Linux 2023 inside Lambda.
LewisCowlesMotive commented 3 months ago

It's the bootstrap from the zip above I'm missing. we're doing the other stuff. So Bootstrap will take our code and launch it via the different runtime?

I Had mounted the zip as a lambda layer, and then copied the handler from the SAM example.

richarddavison commented 3 months ago

Kind of, I recommend reading here: https://docs.aws.amazon.com/lambda/latest/dg/runtimes-custom.html

richarddavison commented 3 months ago

@LewisCowlesMotive I'm closing now. Feel free to add comments here if you still need help :)