Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
A Node.js library to run CPU-intensive tasks and not block the event loop (github.com/allegro)
21 points by kiyanwang on Aug 21, 2017 | hide | past | favorite | 4 comments


How is this superior to clustering? https://nodejs.org/api/cluster.html


They are different.

Clustering is useful for when the requests have roughly the same cost and serves to distribute that load over several cpus roughly evenly (because a NodeJS is single threaded you need this to take full advantage of modern hardware).

Workers are useful when requests vary greatly in cost (some far outweighing the others) so that the event loop is not blocked for less costly tasks by much more costly ones.

Consider a web application serving http requests. You would want to multiplex those requests over available cpus on a machine with workers but would not want to block processing any of those individual cluster workers with expensive requests.


Any reason this doesn't use the cluster API? As far as I can tell it uses `child_process` but `cluster` could accomplish the same thing, easier, and it's what it is meant to do.


Very cool... this could be extremely useful to me. I've been doing a fair amount of ETL work, and quite a bit of it could be more parallel.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: