I am not able to find out whether libuv in node.js uses multi core cpus or it runs all of its threads in on single core only using time slicing? As node.js is single threaded but libuv has its own thread pool so does it use all the cores of multi core cpu?
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- void before promise syntax
- npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fs
- Keeping track of variable instances
A Node.js server can use all cores through the
Cluster
module. Otherwise it will not, unless you build your application as multiple processes which is a common pattern.It does leverage multicores via the threadpool. e.g., on Linux, the underlying pthreads will uses multiple cores for multiple threads.
If you run the following code, you will notice 4 (default threadpool size) cores will peg at 100% as file system IO are running with the threadpool.