Back to articles
Why we replaced Node.js with Bun for 5x throughput

Why we replaced Node.js with Bun for 5x throughput

via Dev.to JavaScriptNick

We replaced Node.js with Bun in one of our most latency-sensitive services and got a 5x throughput increase. We also found a memory leak that only exists in Bun's HTTP model. The service is called Firestarter. It's our warm start connection broker: it holds thousands of long-poll HTTP connections from idle run controllers, each waiting for work. When a task run arrives, Firestarter matches it to a waiting controller and sends the payload through the held connection. No cold start, no container spin-up. It's in the critical path of every task execution on Trigger.dev. The problem: Firestarter was using too much CPU. It was running on Node.js, spending 31% of its time inside a SQLite query, parsing every request with Zod, and converting headers with Object.fromEntries() on every GET. It worked, but it was slow. It took four rounds of profiling to get there, and we hit a few Bun surprises we haven't seen documented elsewhere. Phase 1: kill the SQLite query engine The original connection m

Continue reading on Dev.to JavaScript

Opens in a new tab

Read Full Article
0 views

Related Articles