Guide · Serverless & AWS
Bun on AWS Lambda: cold starts vs Node.js 24
Bun starts faster than Node.js on your laptop, so it's tempting to assume it will on Lambda too. The published numbers say otherwise: Bun's cold starts are about 3.5× slower than AWS's managed Node.js runtime. Below is everything published so far, what changed in 2025–2026 with Node.js 24, INIT billing and SnapStart, and a script to measure your own function.
The short answer
- Cold starts: managed Node.js wins. In the largest published test, Bun's median cold start was 527 ms against 151 ms.
- Warm invocations: Node.js won there too, 8.1 ms against 15.2 ms median. Bun's speed on a server doesn't carry over to Lambda.
- Node.js 24 hasn't been benchmarked against Bun by anyone I could find. It's the current LTS runtime on Lambda, so it's the one to measure. The script below takes a few minutes.
- Best of both: use Bun to install, test and bundle, and deploy the output to the managed
nodejs24.xruntime.
What the published benchmarks show
Bun isn't a managed Lambda runtime, so every test below runs it as a custom runtime, mostly with the official bun-lambda layer. The most thorough test is Jason Butz's from May 2025. It recorded 1,326 invocations per runtime, 70 of them cold starts, and read the timings from Lambda's own REPORT logs.
| Source | Setup | Bun cold start | Node.js cold start |
|---|---|---|---|
| Jason Butz, May 2025 | bun-lambda layer vs managed Node.js, 70 cold starts each, SHA3 hashing | 527 ms median, 603 ms p90 | 151 ms median, 160 ms p90 |
| Jason Butz, Apr 2025 | bun-lambda layer, JWT signing, 3 cold starts | 629 ms average | 135 ms average (Node.js 22) |
| Serverless By Theodo, Sep 2023 | bun-lambda layer via SST, arm64, 1,024 MB | About 500 ms | Not given. Warm Bun was about 2× slower |
| Lumigo (Yan Cui), Sep 2023 | Review of earlier benchmarks | Bun's cold starts are much higher because a custom runtime misses Lambda's built-in optimisations | |
Warm invocations in the May 2025 test followed the same pattern: a median of 8.1 ms for Node.js against 15.2 ms for Bun. Deno, running in a container image, was fastest at 6.7 ms.
You'll also find a 2026 post claiming Bun is "3× faster than Node.js 22" on Lambda. It says it was written by AI, it times the call from the client (network and SDK included), and it doesn't show the function code. I left it out.
Why Bun is slower on Lambda
- It's a custom runtime. AWS tunes and caches its managed runtimes. A custom runtime starts from your layer or image, so the Bun binary has to start from scratch on every cold start.
- The adapter adds a layer. The
bun-lambdaruntime receives each Lambda event and turns it into a webRequestfor yourfetchhandler. Non-HTTP events (SQS, S3, EventBridge) arrive as the request body. - Bun's strengths don't apply. Bun is fast at serving lots of HTTP requests from one long-running process. A Lambda environment handles one request at a time, so there's little for Bun to win there.
This is specific to Lambda. On containers that keep running, like Fargate, Cloud Run or a VPS, there's no custom runtime layer in the way, and one process serves many requests. For that comparison, see Bun vs Node.js in production.
What changed with Node.js 24 on Lambda
AWS added Node.js 24 on 25 November 2025, as the nodejs24.x managed runtime and as a container base image, both on Amazon Linux 2023.
- New Runtime Interface Client. The code that connects your handler to Lambda was rewritten for this runtime.
- Callback handlers are gone. A handler with a
callbackparameter fails withRuntime.CallbackHandlerDeprecated. Useasynchandlers. - Supported until 2028. AWS lists 30 April 2028 as the deprecation date, so it's the runtime to target for new functions.
I haven't found a published cold-start comparison of nodejs24.x against nodejs22.x or Bun. If cold starts matter to you, measure your own function. That's more useful than any benchmark anyway, because your dependencies and bundle size affect the result more than the runtime version does.
Do cold starts cost more now?
Since 1 August 2025, Lambda bills the INIT phase for ZIP functions on managed runtimes too. Custom runtimes like Bun's were always billed for it. So both runtimes pay for cold starts, and Bun simply has a longer one.
An example with the May 2025 numbers: 1 million invocations a month, 1% of them cold starts, 1,024 MB on arm64 at $0.0000133334 per GB-second:
| Extra time with Bun | Calculation | Extra cost per month |
|---|---|---|
| Cold starts: 376 ms longer | 10,000 × 0.376 s × 1 GB | About $0.05 |
| Invocations: about 7 ms longer | 1,000,000 × 0.007 s × 1 GB | About $0.09 |
So the bill isn't the problem: about 14 cents per million calls. The problem is latency. A user who hits a cold start waits almost 400 ms longer, and for an API behind API Gateway that's very noticeable. My Lambda cost optimization guide covers the changes that move the bill much more: arm64, right-sizing memory and smaller bundles.
Does SnapStart change the picture?
SnapStart restores a function from a snapshot taken after initialisation, so the INIT phase doesn't run again on each cold start. Until September 2026 it only worked with Java, Python and .NET. On 2 September 2026 AWS added SnapStart for container images:
- Not for the
nodejs24.xZIP runtime. The SnapStart docs still list it as unsupported. - Node.js container images can opt in with
LABEL com.amazonaws.lambda.feature.snapstart="Allow"in the Dockerfile, or by implementing the runtime hooks. - Custom base images follow the same rules, so a Bun container image should be able to opt in too. I haven't found anyone who has published results for Bun with SnapStart.
Don't expect it to help a small function. In a September 2026 test by Classmethod with a Node.js 22 container image, a minimal function took 274 ms without SnapStart and 418 ms with it. It only paid off with heavy initialisation: a function that took 2.1 s to initialise restored in 546 ms.
SnapStart also has its own costs and limits: a charge for keeping each snapshot cached (minimum 3 hours per published version), a charge per restore, it only works on published versions, and publishing took about a minute in that test. Use it for functions that load something large at startup, not as a general fix.
Measure it yourself
Your dependencies and bundle size affect cold starts more than the runtime does, so measure your own function. Deploy the same small handler on both runtimes with the same memory and architecture, then force cold starts and read Init Duration from the REPORT log line.
export const handler = async () => ({
runtime: "node",
version: process.version,
});export default {
async fetch(request: Request): Promise<Response> {
return Response.json({ runtime: "bun", version: Bun.version });
},
};Build and publish the Bun layer once, following the bun-lambda README, then deploy both functions. The README still mentions Amazon Linux 2; for a new function I'd use provided.al2023, the current OS-only runtime.
# Bun layer (once per region and architecture)
git clone --filter=blob:none --sparse https://github.com/oven-sh/bun.git
git -C bun sparse-checkout set packages/bun-lambda
cd bun/packages/bun-lambda && bun install
bun run publish-layer -- --arch aarch64 --region eu-central-1
cd -
ROLE=arn:aws:iam::<account-id>:role/<lambda-basic-execution-role>
# Node.js 24
zip node.zip index.mjs
aws lambda create-function --function-name cold-node24 \
--runtime nodejs24.x --architectures arm64 --memory-size 1024 \
--handler index.handler --zip-file fileb://node.zip --role "$ROLE"
# Bun
bun build handler.ts --outfile ./dist/handler.js
(cd dist && zip ../bun.zip handler.js)
aws lambda create-function --function-name cold-bun \
--runtime provided.al2023 --architectures arm64 --memory-size 1024 \
--handler handler.fetch --zip-file fileb://bun.zip --role "$ROLE" \
--layers <bun-layer-version-arn>Changing an environment variable forces Lambda to start a fresh environment, so every run below is a real cold start:
#!/usr/bin/env bash
# Usage: ./cold-starts.sh <function-name> [runs]
# Use test functions only: this replaces the function's environment variables.
set -euo pipefail
fn="$1"; runs="${2:-30}"
for i in $(seq 1 "$runs"); do
aws lambda update-function-configuration --function-name "$fn" \
--environment "Variables={COLD_START_RUN=$i}" > /dev/null
aws lambda wait function-updated --function-name "$fn"
aws lambda invoke --function-name "$fn" --log-type Tail \
--query LogResult --output text /dev/null \
| base64 --decode | grep -o 'Init Duration: [0-9.]* ms'
done | awk '{print $3}' | sort -n \
| awk '{v[NR]=$1} END {print "cold starts:", NR, " median:", v[int((NR+1)/2)], "ms p90:", v[int(NR*0.9+0.5)], "ms"}'Run it for both functions, for example ./cold-starts.sh cold-node24 30 and ./cold-starts.sh cold-bun 30. That's 60 short invocations, which costs a fraction of a cent. Delete the functions and the layer afterwards. To test your real function, deploy a copy of it instead of the hello-world handler.
Which one should you use?
| Your situation | Use | Why |
|---|---|---|
| APIs and anything a user waits for | Managed nodejs24.x, arm64, bundled | Fastest published cold starts, patched by AWS |
| You like Bun's tooling | Bun to build and test, Node.js 24 to run | bun build --target node gives you a bundle for the managed runtime |
You depend on Bun-only APIs, like bun:sqlite | Bun in a container on Fargate or Cloud Run, or the Lambda layer if a 0.5 s cold start is acceptable | A long-running container plays to Bun's strengths |
| Heavy startup, like loading models or large files | Container image with SnapStart, measured on your function | SnapStart helped in tests only when initialisation took 2 s or more |
| Background jobs: queues, cron, batch | Either | Nobody waits for the cold start, and the cost difference is cents |
About these numbers
- All benchmark figures here come from the linked sources. I haven't run my own Bun-on-Lambda benchmark for this article; the script above is how to do it.
- The sources used different workloads, memory sizes and Bun versions, and several didn't publish them. Compare the ratios, not the exact milliseconds.
- The 2023 results come from early Bun versions. The 2025 results are newer, but they still use the layer approach, which hasn't changed in principle: Bun is still a custom runtime.
FAQ
Is Bun faster than Node.js on AWS Lambda?
Not in the published tests. In the largest one, with 70 cold starts per runtime, Bun's median cold start was 527 ms against 151 ms for AWS's managed Node.js runtime, and its median invocation took 15.2 ms against 8.1 ms. Bun runs as a custom runtime on Lambda, so it misses the optimisations AWS builds into its managed runtimes.
Does AWS Lambda support Bun?
Not as a managed runtime. You run Bun as a custom runtime, either with the bun-lambda layer from the Bun repository on an OS-only runtime, or in your own container image. AWS doesn't patch or tune either option for you.
How fast is a Node.js 24 cold start on Lambda?
As of December 2026 I haven't found a published Node.js 24 cold-start benchmark. Managed Node.js cold starts were around 135–150 ms for small functions in 2025 tests. Node.js 24 (nodejs24.x) ships a new Runtime Interface Client, so measure your own function: the script in this guide does that in a few minutes.
Am I billed for Bun's cold start on Lambda?
Yes. Custom runtimes have always been billed for the INIT phase. Since 1 August 2025, ZIP functions on managed runtimes like Node.js are billed for it too, so both pay for cold starts. Bun's longer INIT costs a little more, but for most workloads the extra latency matters more than the extra cost.
Can I use Lambda SnapStart with Node.js 24 or Bun?
Not with the nodejs24.x ZIP runtime. Since September 2026 SnapStart works with container images, and Node.js or custom images opt in with a Dockerfile label or by implementing runtime hooks. A Bun image should qualify under the custom-image rules, but I haven't found published results. In one test SnapStart only helped Node.js functions with more than about 2 seconds of initialisation.
Can I use Bun without running it on Lambda?
Yes, and it's usually the best trade-off. Use Bun to install, test and bundle (bun build --target node), then deploy the bundle to the managed nodejs24.x runtime. You keep Bun's fast tooling and get Node's fast cold starts on Lambda.