Repository navigation
Replies: 2 comments
|
Hi! Thanks for the detailed report and the reproduction repo — that makes this much easier to dig into. I can't confirm a single root cause from the report alone, but there are two verified configuration issues in your setup that fit your symptoms exactly, plus a few diagnostics to narrow it down. 1. You are most likely benchmarking the dev server, not a production build With HTML imports, Bun has two modes (see https://bun.com/docs/api/http, "HTML imports"):
Running For production, build the server entry point first and run the output: bun build --target=bun ./src/server.tsx --outdir=./dist
bun ./dist/server.js(The exact entry file depends on your project — it is whichever file calls 2. The default From the same docs page ("idleTimeout"): by default If your handlers can legitimately take a while to produce the first byte, raise it: Bun.serve({
fetch(req) { /* ... */ },
// 0 disables the timeout entirely; max is 255
idleTimeout: 30,
});Or disable it per long-lived request with 3. Scale across cores with A single Bun process runs JavaScript on one thread, so one process can only do so much accepting and queueing. Bun's documented way to use all cores is Bun.serve({
port: 3000,
reusePort: true, // Linux only
fetch(req) { /* ... */ },
});Then start one process per core. 4. How to confirm which of these it is
To directly answer your three questions: (1) no, a ~94% success rate under load is not the expected behaviour for a production-built Bun server; (2) the two documented limits most likely involved here are on-demand bundling in dev mode and the 10s Hope that helps, and it would be great if you could report back the numbers from the prebuilt run — that would tell us whether there is a real server bug left to chase here. References:
|
|
I don't think Bun is dropping completed requests. In
I'd rerun with — |
Uh oh!
There was an error while loading. Please reload this page.
Hi everyone,
I’ve been testing Bun’s performance under load, and noticed something strange compared to other frameworks.
Even though Bun shows excellent average response times, the success rate is significantly lower - many requests just fail with
ETIMEDOUT, even though the server remains responsive.Benchmark results
So while Bun Preact is extremely fast in terms of latency, it fails to handle all incoming requests reliably.
The success rate drops to around 94%, with thousands of
ETIMEDOUTresponses, even though CPU and memory usage stay normal.You can see my demo and test setup here:
👉 https://github.com/s00d/bun-demo
The repo contains a minimal Bun + Preact app, tested with Artillery under load.
It’s a very simple setup, no complex middleware or routing - just enough to reproduce the behavior.
It runs fine under normal conditions, but starts dropping requests as soon as concurrency grows.
What I tried
I suspected this might be related to how the server or build is run in production mode.
Using the default template:
This produces a
distfolder with a client build.However, starting the app like this:
still serves pages dynamically from
src, importingindex.htmlat runtime.So it’s unclear if this is the intended "production" mode or just a dev-style server.
If I try to build the entire server entry (
./src/server.tsx) with--splitting, the server breaks.If I build server and client separately, it only works when both are in the same directory,
which makes real deployment complicated (for example, when hosting multiple apps on one domain).
Questions
src?Thanks in advance - I’ve read through a lot of the docs, but couldn’t find a clear explanation of how production serving should behave or why some requests fail under load while the server appears healthy.
All reactions