LLRT
LLRT (Low Latency Runtime) is a lightweight JavaScript runtime designed to address the growing demand for fast and efficient Serverless applications. LLRT offers up to over 10x faster startup and up to 2x overall lower cost compared to other JavaScript runtimes running on AWS Lambda
It's built in Rust, utilizing QuickJS as JavaScript engine, ensuring efficient memory usage and swift startup.
LLRT is an experimental package. It is subject to change and intended only for evaluation purposes.
Configure Lambda functions to use LLRT
Download the last LLRT release from
Option 1: Custom runtime (recommended)
Choose Custom Runtime on Amazon Linux 2023 and package the LLRT bootstrap binary together with your JS code.
Option 2: Use a layer
Choose Custom Runtime on Amazon Linux 2023, upload llrt-lambda-arm64.zip or llrt-lambda-x86.zip as a layer and add to your function
That's it 🎉
Even though LLRT supports ES2020 it'sNOT a drop in replacement for Node.js. Consult Compatibility matrix and API for more details.
All dependencies should be bundled for a browser platform and mark included @aws-sdk packages as external.
Option 3: AWS SAM
instrumented with a layer containing the llrt runtime.
Option 4: AWS CDK
You can use [cdk-lambda-llrt construct library](https://github.com/tmokmss/cdk-lambda-llrt) to deploy LLRT Lambda functions with AWS CDK.
- ```ts
- import { LlrtFunction } from 'cdk-lambda-llrt';
- const handler = new LlrtFunction(this, 'Handler', {
- entry: 'lambda/index.ts',
- });
- ```
Testing & ensuring compatibility
The best way to ensure that your code is compatible with LLRT is to write tests and executing them via the built in test runner
Test runner
Test runner uses a lightweight Jest-like API and uses the
assert module from Node.js for test assertions. For examples how to implement tests for LLRT see the
/tests folder of this repository.
To run tests, execute the `llrt test` command. LLRT scans the current directory and sub-directories for files that ends with `*.test.js` or `*.test.mjs`. You can also provide a specific test directory to scan by using the `llrt test -d ` option.
The test runner also has support for filters. Using filters is as simple as adding additional command line arguments, i.e: llrt test crypto will only run tests that match the filename containing crypto.
Compatibility matrix
LLRT only support a fraction of the Node.js APIs. It is NOT a drop in replacement for Node.js, nor will it ever be. Below is a high level overview of partially supported APIs and modules. For more details consult the API documentation
| | LLRT |
---|
------------- | ---------------------------------------- |
buffer | ✔︎ |
streams | ✔︎ |
child_process | ✔︎ |
net:sockets | ✔︎ |
net:server | ✔︎ |
tls | ✔︎ |
fetch | ✔︎ |
http | ✔︎ |
https | ✔︎ |
fs/promises | ✔︎ |
fs | ✔︎ |
path | ✔︎ |
timers | ✔︎ |
uuid | ✔︎ |
crypto | ✔︎ |
process | ✔︎ |
encoding | ✔︎ |
console | ✔︎ |
events | ✔︎ |
ESM | ✔︎ |
CJS | ✔︎ |
async/await | ✔︎ |
Other | ✔︎ |
_⚠️ = partially supported in LLRT_
_⏱ = planned partial support_
_\* = Not native_
_\\ = Use fetch instead_