Menu

1 / 2

BunOnLambda Is 3x Faster But Breaks 20% Of NodeJsApis

DEV Community·Dinesh_gowtham·6 months ago
#ILQt4MWe
#lambda#bunjs#node#serverless#const
Reading 0:00
15s threshold

We ran BunOnLambda for 60 days and achieved 3x faster cold starts than Node.js 22, but 20% of our Node.js APIs broke due to missing net.Socket and crypto APIs. Here's what we learned from the experiment and how we fixed the broken APIs.

Introduction to BunOnLambda

BunOnLambda is a custom runtime for AWS Lambda that offers significant performance gains compared to traditional Node.js runtimes. To get started with BunOnLambda, you'll need to create a new Lambda function with the BunOnLambda runtime.

import { CreateFunctionCommand } from ' @aws-sdk/client-lambda ' ;

const lambdaClient = new LambdaClient ({ region : ' us-east-1 ' });

const params = { FunctionName : ' my-bun-on-lambda-function ' , Runtime : ' bun ' , Role : ' arn:aws:iam::123456789012:role/lambda-execution-role ' , Handler : ' index.handler ' , Code : { ZipFile : Buffer . from ( ' export function handler() {} ' , ' utf8 ' ), }, };

const run = async () => { try { const data = await lambdaClient .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.