3 ms·
How is this superior to clustering? https://nodejs.org/api/cluster.html https://nodejs.org/api/cluster.html
by stevenmays 9y ago
How is this superior to clustering? https://nodejs.org/api/cluster.html https://nodejs.org/api/cluster.html
- tbrock 9y agoThey 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.