Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is Node.js scalable?

Tags:

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?

like image 922
vuvu Avatar asked Jun 05 '13 20:06

vuvu


People also ask

Why is node JS highly scalable?

it is scalable due to load balancing. Essentially you can have multiple jobs for node to process and it can handle it with no significant burden. This makes it scalable.

Is node JS server scalable?

Scaling your Node. js application horizontally across multiple machines is similar to scaling across multiple cores on a single machine. As long as your application can run as an independent process, it can be distributed to run across several machines.

How much scalable node js is?

By avoiding all that, Node. js achieves scalability levels of over 1M concurrent connections, and over 600k concurrent websockets connections. There is, of course, the question of sharing a single thread between all clients requests, and it is a potential pitfall of writing Node. js applications.

Is Nodejs more scalable than Java?

For example, you can develop an application in Java and link to it with JavaScript through an engine like Rhinorun. However, in a real-world scenario, picking Node. js for your web application makes more sense. It's just faster and more scalable than Java, when it comes to web apps.


1 Answers

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

like image 155
jedigo Avatar answered Oct 14 '22 05:10

jedigo