frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

Node.js worker threads are problematic, but they work great for us

https://www.inngest.com/blog/node-worker-threads
29•goodoldneon•3d ago

Comments

vilequeef•1h ago
It’s not weird that you can’t share state between totally different processes except by passing in args.

And you can make it thread-like if you prefer by creating a “load balancer” setup to begin with to keep them CPU bound.

    require('os').cpus().length
Spawn a process for each CPU, bind data you need, and it can feel like multithreading from your perspective.

More here https://github.com/bennyschmidt/simple-node-multiprocess

socketcluster•54m ago
I love the simplicity of Node.js that each process or child process can have its own CPU core with essentially no context switching (assuming you have enough CPU cores).

Most other ways are just hiding the context switching costs and complicating monitoring IMO.

derodero24•1h ago
I went through a similar journey trying worker threads for CPU-bound work in Node. The serialization cost of passing data between threads ate most of my gains, especially with larger inputs. Ended up going the napi-rs route instead — Rust addon running in the main thread with near-zero FFI overhead. Different tradeoff since you lose the parallelism, but for my workload the raw speed was already enough.
socketcluster•1h ago
I like Node.js' simple and fully isolated concurrency model. You shouldn't be blocking the main event loop for 30 seconds! The main event loop is not intended to be used for heavy processing.

You can just set up a separate child process for that. The main event loop which handles connections should just co-ordinate and delegate work to other programs and processes. It can await for them to complete asynchronously; that way the event loop is not blocked.

I recall people have been able to get up to around a million (idle) WebSocket connections handled by a single process.

I was able to comfortably get 20k concurrent sockets per process each churning out 1 outbound message every 3 to 5 seconds (randomized to spread out the load).

It is a good thing that Node.js forces developers to think about this because most other engines which try to hide this complexity tend to impose a significant hidden cost on the server in the form of context switching... With Node.js, there is no such cost, your process can basically have a whole CPU core for itself and it can orchestrate other processes in a maximally efficient way if you write your code correctly... Which Node.js makes very easy to do. Spawning child processes and communicating with them in Node.js is a breeze.

ptrwis•1h ago
I'm currently writing simulations of trading algorithms for my own use. I'm using worker_threads + SharedArrayBuffer and running them in Bun. I also tried porting the code to C# and Go, but the execution time ended up being very similar to the Bun version. NodeJS was slower. Only C gave a clear, noticeable performance advantage — but since I haven't written C in a long time, the code became significantly harder to maintain.
Jcampuzano2•1h ago
I get its a constraint of the language but the ubiquitousness of bundlers and differing toolchains in the JS world has always made me regret trying to use worker primitives, whether they be web workers, worker threads and more. Not to mention trying to ship them to users via a library being a nightmare as mentioned in the article.

Almost none of them treat these consistently (if they consider these at all) and all require you to work around them in strange ways.

It feels like there is a lot they could help with in the web world, especially in complex UI and moving computation off the main thread but they are just so clunky to use that almost nobody tries to work around it.

The ironic part is if bundlers, transpilers, compilers etc. weren't used at all they would probably have much more widespread use.

rco8786•9m ago
Yea, for the vast, vast majority of workloads just forking separate node process ends up being better than mucking with threads.
baublet•58m ago
Reading the article, I didn’t see this answered: why not scale to more nodes if your workload is CPU bound? Spin off 1 cpu and a few gb of ram container and scale that as wide as you need?

e.g., this certainly helps when the event loop is blocked, but so could FFI calls to another language for the CPU bound work. I’d only reach for a new Node thread if these didn’t pan out, because there’s usually a LOT that goes into spinning up a new node process in a container (isolating the data, making sure any bundlers and transpilers are working, making sure the worker doesn’t pull in all the app code, etc.).

Side car processes aren’t free, either. Now your processes are contending for the same pool of resources and can’t share anything, which IME means more likelihood of memory issues, esp if there isn’t anything limiting the workers your app can spawn.

Still, good article! Love seeing the ways people tackle CPU bound work loads in an otherwise I/O bound Node app.

n_e•49m ago
> but so could FFI calls to another language for the CPU bound work

Worker threads can be more convenient than FFI, as you don't need to compile anything, you can reuse the main application's functions, etc.

groundzeros2015•45m ago
- you should be using multiple node processes - you should be spawning tools to do heavy computation
chrisweekly•42m ago
Related tangent: Platformatic's "Watt" server^1 takes a pretty interesting approach to Node, leveraging worker threads on all available cores for maximum efficiency.

1. https://docs.platformatic.dev/docs/overview/architecture-ove...

Bored of eating your own dogfood? Try smelling your own farts

https://shkspr.mobi/blog/2026/03/bored-of-eating-your-own-dogfood-try-smelling-your-own-farts/
103•ColinWright•1h ago•29 comments

Flash-Moe: Running a 397B Parameter Model on a Mac with 48GB RAM

https://github.com/danveloper/flash-moe
136•mft_•3h ago•48 comments

Building an FPGA 3dfx Voodoo with Modern RTL Tools

https://noquiche.fyi/voodoo
20•fayalalebrun•1h ago•0 comments

A Case Against Currying

https://emi-h.com/articles/a-case-against-currying.html
28•emih•1h ago•24 comments

Nintendo's not-AI, not-a-game toy

https://tapestry.news/culture/nintendo-talking-flower/
14•zygon•42m ago•4 comments

Project Nomad – Knowledge That Never Goes Offline

https://www.projectnomad.us
41•jensgk•2h ago•7 comments

Brute-Forcing My Algorithmic Ignorance with an LLM in 7 Days

http://blog.dominikrudnik.pl/my-google-recruitment-journey-part-1
24•qikcik•2h ago•10 comments

Convincing Is Not Persuading

https://blog.alaindichiappari.dev/p/convincing-is-not-persuading
10•alainrk•1h ago•8 comments

Hormuz Minesweeper – Are you tired of winning?

https://hormuz.pythonic.ninja/
455•PythonicNinja•5h ago•286 comments

A Review of Dice That Came with the White Castle

https://boardgamegeek.com/thread/3533812/a-review-of-dice-that-came-with-the-white-castle
32•doener•3d ago•4 comments

Node.js worker threads are problematic, but they work great for us

https://www.inngest.com/blog/node-worker-threads
29•goodoldneon•3d ago•11 comments

More common mistakes to avoid when creating system architecture diagrams

https://www.ilograph.com/blog/posts/more-common-diagram-mistakes/
33•billyp-rva•2h ago•13 comments

25 Years of Eggs

https://www.john-rush.com/posts/eggs-25-years-20260219.html
125•avyfain•3d ago•43 comments

$ teebot.dev – from terminal to tee in 6 seconds

https://teebot.dev
13•foxpress•2h ago•9 comments

Why Lab Coats Turned White

https://www.asimov.press/p/lab-coat
12•mailyk•3d ago•1 comments

My first patch to the Linux kernel

https://pooladkhay.com/posts/first-kernel-patch/
154•pooladkhay•2d ago•28 comments

Revise – An AI Editor for Documents

https://revise.io
16•artursapek•1h ago•9 comments

Tinybox – A powerful computer for deep learning

https://tinygrad.org/#tinybox
537•albelfio•18h ago•309 comments

Show HN: Crack – Turn your MacBook into a squeaky door

http://crackmacapp.com/
8•ronreiter•59m ago•7 comments

How We Synchronized Editing for Rec Room's Multiplayer Scripting System

https://www.tyleo.com/blog/how-we-synchronized-editing-for-rec-rooms-multiplayer-scripting-system
9•tyleo•2h ago•8 comments

Some things just take time

https://lucumr.pocoo.org/2026/3/20/some-things-just-take-time/
769•vaylian•23h ago•246 comments

The three pillars of JavaScript bloat

https://43081j.com/2026/03/three-pillars-of-javascript-bloat
391•onlyspaceghost•12h ago•228 comments

Professional video editing, right in the browser with WebGPU and WASM

https://tooscut.app/
315•mohebifar•17h ago•113 comments

Turns out your coffee addiction may be doing your brain a favor

https://www.theregister.com/2026/03/21/turns_out_your_coffee_addiction/
24•Bender•1h ago•4 comments

Chest Fridge (2009)

https://mtbest.net/chest-fridge/
149•wolfi1•13h ago•79 comments

HopTab–free,open source macOS app switcher and tiler that replaces Cmd+Tab

https://www.royalbhati.com/hoptab
68•robhati•8h ago•20 comments

Vatican Rebukes Peter Thiel's Antichrist Lectures in Rome

https://www.thenerdreich.com/peter-thiels-antichrist-circus-smacked-down-in-rome/
97•vrganj•5h ago•64 comments

'Miracle': Europe reconnects with lost spacecraft

https://phys.org/news/2026-03-miracle-europe-reconnects-lost-spacecraft.html
68•vrganj•4h ago•28 comments

Floci – A free, open-source local AWS emulator

https://github.com/hectorvent/floci
232•shaicoleman•16h ago•73 comments

The IBM scientist who rewrote the rules of information just won a Turing Award

https://www.ibm.com/think/news/ibm-scientist-charles-bennett-turing-award
7•rbanffy•2h ago•0 comments