Why is Node.js scalable?

vuvu picture vuvu · Jun 5, 2013 · Viewed 12.9k times · Source

node.js scalable, what is meant by the that? What part of a node.js server is scalable. I read that it is a single-threaded technology that is not suitable for applications that would need a lot of CPU resources. These facts do not fit with scalability, so what is meant by that?

Answer

jedigo picture jedigo · Jun 5, 2013

The javascript that node runs is single threaded, but a lot of the things you call in node - such as network or file io - run in background threads. See this post for a basic overview: Node is not single threaded

If you need the gritty details, you should look into libuv which is the 'magic' piece converting threads into event loops: http://nikhilm.github.io/uvbook/basics.html#event-loops

Additionally, if you need to do something CPU intensive in node itself, you can easily send this to a child process - see http://nodejs.org/api/child_process.html#child_process_child_process_fork_modulepath_args_options for details