Coder Social home page Coder Social logo

aws-llrt-talk's Introduction

AWS Lambda Runtimes Comparison: Node.js vs Bun vs Deno.js vs LLRT

Table of Contents

  1. Introduction
  2. Project Structure
  3. Lambda Functions
  4. Deployment with AWS CDK
  5. Getting Started
  6. Results and Analysis
  7. License

Introduction

This project aims to compare the performance and ease of use of four JavaScript runtimes: Node.js, Bun, Deno.js, and LLRT (Latest JavaScript Runtime from AWS Labs). We achieve this by implementing three common Lambda functions:

  1. Hello World: A simple benchmarking function to measure cold start and execution times.
  2. Weather Extraction: A Lambda function with Gen AI according to today's weather forecast stored in DynamoDB, extracts rainy forecast from the forecast, and return the result.

All Lambda functions are deployed using the AWS Cloud Development Kit (CDK) to ensure replicability and ease of deployment.

Project Structure

The project is organized as follows:

aws-lambda-runtimes-comparison/
│
├── bin/
│   └── benchmark.ts
├── lib/
│   ├── hello-world-stack.ts
│   ├── dynamodb-bedrock-stack.ts
├── layer/
│   ├── bun/
│   ├── llrt/
├── lambda/
│   ├── hello-world/
│   ├── dynamodb-bedrock/
├── cdk.json
├── LICENSE
└── README.md

Lambda Functions

Hello World Benchmarking

A simple "Hello World" Lambda function used for benchmarking the cold start and execution times of different runtimes. We tried our best to share the same implementation across each runtime (Node.js, Bun, Deno.js, LLRT) for comparability.

Forecast Extraction

This Lambda function with Gen AI based on weather forecast stored in DynamoDB. It also added the date-fns package. It performs the following steps:

  1. Fetches today weather forecast from DynamoDB.
  2. Extracts rainy forecast from the text through AWS Bedrock Claude 3.
  3. Return the result.

Deployment with AWS CDK

The project uses AWS CDK to define and deploy the infrastructure. Each Lambda function is defined in a separate stack, making it easy to manage and deploy individually.

Getting Started

Prerequisites

Before you begin, ensure you have the following installed:

  • Node.js
  • AWS CLI
  • AWS CDK

Installation

Clone the repository and install the dependencies:

git clone https://github.com/teckyio/aws-lambda-runtimes-comparison.git
cd aws-lambda-runtimes-comparison/cdk
pnpm install 

Binaries

You may download the binaries for the runtimes from the following links:

Download and replace the runtime located in ./layer/bun and ./layer/llrt if necessary.

Deployment

Deploy the CDK stacks to your AWS account:

cdk bootstrap
cdk deploy --all

Running the Benchmarks

Invoke the Lambda functions to collect benchmarking data:

time aws lambda invoke --no-cli-pager --function-name (function name created by cdk) /dev/null

Results and Analysis

After running the benchmarks, analyze the results to compare the performance of each runtime. Key metrics to consider include cold start times, execution times, and memory usage.

License

This project is licensed under the MIT License. See the LICENSE file for details.

aws-llrt-talk's People

Contributors

alexlau811 avatar

Stargazers

Gordon Lau Wai Chung avatar

Watchers

Gordon Lau Wai Chung avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.