oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
73.33k stars 2.69k forks source link

Cold start benchmarks for Bun.serve() #2373

Open effulgentsia opened 1 year ago

effulgentsia commented 1 year ago

What is the type of issue?

Documentation is missing

What is the issue?

On https://bun.sh/, the first bullet point for "What is Bun?" is:

Fast startup. This is more important than ever as edge computing environments make cold start times more important than ever.

I'd love to know what a reasonable expectation is for how fast that cold start is and how it compares to Node.

I did a quick test on Fly.io, which uses Firecracker VMs. The VM itself cold starts in ~300ms, and then it takes an additional 300ms from executing bun run server.js until Fly.io detects that port 8080 is being listened on, where server.js is the following:

export default {
  fetch(req) {
    return new Response(`Bun!`);
  },
}

Is 300ms cold start (on top of Firecracker's 300ms cold start) in line with Bun's expectations? If there was documentation available comparing cold start benchmarks, then I'd know if what I'm seeing on Fly.io is normal or something unusual that I should try to investigate further.

Thanks!

Where did you find it?

No response

mickdekkers commented 1 year ago

Semi-related*, but there's an open source AWS Lambda benchmarks project available at maxday/lambda-perf that just added bun support.

Bun 1.0 results on the cold start front are disappointing, unfortunately. Cold start times as of this writing are the slowest on the list at ~450ms, being slower even than Java 11 at ~280ms.

Hopefully, future updates to Bun will improve this metric, but right now I'd think twice about choosing Bun for FaaS 😕

* Semi-related because this benchmark doesn't test web servers, only barebones AWS Lambda function calls

ian-pascoe commented 11 months ago

I agree and unfortunately this is a major hindrance for me to adopting bun. Node cold start is faster and node is more stable/supported.. it's a no-brainer to keep using node for the time being.