Profile photo for Julian Jensen

A cluster is when you have two or more node instances running with one master process routing incoming requests (or whatever tasks you want) to one of the worker instances. I find that this is generally better achieved using a real router or more complex node.js solutions, like pm2, for example. This is what I tend to use on production servers. Throughput is phenomenal and the server instances are extremely stable.

A child process is much the same as it is in other languages. It simply spawns a new script or executable on the system. It can be anything you have the ability run, not necessarily JavaScript.

Worker pools are only available in the browser where you have a choice of worker types. This is not specifically a JavaScript feature but a browser one. For more information, look here: Using Web Workers

A thread pool pool is a multi-threaded execution model where thread are pre-allocated and kept on hold until a thread is needed. At that point the thread executes its task and, once done, returns to the pool and back on hold. The alleviates the need to allocate threads when the need arises, saving the overhead of thread allocation. It’s about the fastest way, that I know of, to write multi-threaded task-oriented code. This is not something you can implement using vanilla node.js. There are thread libraries out there but I don’t have any personal experience with how well they perform. Examples are fibers and napajs. For an example of a thread pool server, check out the very readable source code for the Apache HTTP server (not node.js but C) thread model: apache/httpd

What node.js really needs but doesn’t have, because it’s not part of the JavaScript spec, is the ability to spawn workers like you can on the web. The web workers actually get their own OS-level thread and the model therefore constitutes actual multi-threading. However, part of the strength of JavaScript is its single-threaded nature. If you find yourself needing multi-threaded execution you most likely doing something that could be better done some other way or something that JavaScript isn’t suited for. JavaScript is not a great choice when you need raw computing power or some kind of computation that requires a lot of CPU load. JavaScript excels at I/O oriented tasks and much less so at computation. Not saying it can’t do it, but if you have a need for that much computing power there are more efficient choices. JavaScript is a great language with very high performance but it’s not always the best choice even if it almost always is the easiest.

View 1 other answer to this question
About · Careers · Privacy · Terms · Contact · Languages · Your Ad Choices · Press ·
© Quora, Inc. 2025