Node.js at scale, rebalanced: how we cut cost by 38%
Booking.com cut compute costs for its largest Node.js React SSR service by 38% (30% fewer pods, 20% less memory per pod, up to 10% lower tail latency) without touching service code, by moving from pm2's cluster-based processes to wattpm worker threads and revisiting long-untouched configuration. Synthetic k6 tests showed 20-50% more throughput within latency SLOs, validated through a side-by-side production A/B split at the routing layer. Production exposed uneven worker load because SO_REUSEPORT's connection hashing interacted badly with nginx loopback connections recycled via tcp_tw_reuse. Giving each worker its own port and load-balancing in nginx fixed it, which also opened the door to smarter balancing between heavy renders and light metadata requests.
Related posts
- Fully Loaded Node – A Node.JS Holiday Season, part 2
Mozilla Hacks mediumAdeptNode.js runs JavaScript on a single core, so CPU-heavy work needs special handling to keep a server responsive. Mozilla Persona's team judged five designs against four goals: saturating all cores, staying responsive, degrading gracefully under overload and integrating simply. Running work on the main thread, wrapping it in a fake-async API, using threaded native libraries (capped by Node's 4-thread internal pool, which also starves I/O) and the cluster module all fall short. Their compute-cluster library runs dedicated worker processes behind an async API, tracks queue depth and average job time, and rejects requests up front when the predicted wait exceeds a client-supplied max_request_time.
- Server rendering benchmarks: Railway vs Cloudflare vs Vercel
Railway mediumAdeptRunning Theo Browne's SSR benchmark suite (400 requests, 20 concurrent connections, from an EC2 client in us-west-1) against Railway with 10 replicas, Cloudflare Workers and Vercel Functions gave mixed results. Railway won SvelteKit and Vanilla JS by roughly 3-4×, React SSR was close, and Vercel and Cloudflare led on Next.js and the math workload. Bun beat Node on Railway for most tests but lost on math. Next.js is limited to a single CPU core, so it only scales horizontally. Node also builds V8 without a faster trig-function path that Workers enables, and container runtimes cost about 40% versus native, a gap Railway expects a new VM runtime to close.
- Node.js and the tale of worker threads
Zalando Engineering mediumAdeptA Node.js service using cluster mode called os.cpus().length inside a Kubernetes container, which returns the host's core count, not the pod's CPU allocation. On a 48-core node it forked 48 processes inside a 2GB pod. Each needed about 120MB, so the processes were killed under memory pressure and immediately re-forked by the exit handler, flooding a translation service with startup requests (1,000 to 20,000 rpm) and causing cancelled connections and read timeouts. The initial diagnosis of a retry feedback loop caused by process.exit() on fetch failure turned out to be wrong. The fix was to drop cluster mode and let Kubernetes handle scaling, and the incident motivated adding event-loop lag and other signals through an internal Node.js observability SDK.
- Bun v1.1.25
Bun mediumAdept
Bun v1.1.25 adds node:cluster support, which lets a pool of workers share one port via reusePort for multi-core HTTP throughput. Load balancing only works as expected on Linux. It also adds an initial V8 C++ API compatibility layer implemented on top of JavaScriptCore, needed because the two engines differ in GC and handle-scope semantics, so native packages like cpu-features now load. The release also enables the OMGJIT WebAssembly JIT on Windows (about 20% faster on a hashing benchmark), makes @aws-sdk/client-s3 uploads 5x faster via a node:http client fix, and lets standalone executables bundle Workers and embedded files through Bun.embeddedFiles. A batch of Node.js compatibility and crash fixes rounds it out.
- How we built JSR
Deno mediumAdeptJSR, the JavaScript Registry, splits into components with different reliability targets: a highly available Postgres cluster behind a Rust/Hyper API on Google Cloud Run targeting 99.9%, and a global CDN for package source and npm tarballs targeting 100% uptime. The jsr.io site uses Fresh's server-side rendering with island hydration and plain HTML forms. TTFB for users far from the US region was cut by eliminating request waterfalls, so no route needs more than one roundtrip between the render server and the API. At publish time, diverse module resolution styles are normalized into an explicit ESM format so consumers never depend on probing.