(NODE) What good is a processor with multiple nuclei if Nodejs only runs on one thread?

Asked

Viewed 126 times

5

Example:

If I want to set up a server, then I have to "worry" about the clock and not the amounts of nuclei ?

Like, if I have two processors to buy

X-Processor -> 8 2.0GHz Nucleus && Y-Processor -> 4 3.0GHz Nucleus

Would it be more advantageous to buy the Y processor for my server ? Because since Nodejs only runs on one thread/Nucleus , then, buying the X processor would be "waste" of 7 nuclei and in the Y processor a "waste" of 3 nuclei, and still with the advantage of having a larger clock !

I don’t know if I’m wrong, but I get why.

If this "theory" of mine is right, what should I do? Change language or apply Threads to my APP ?

  • 3

    For other technologies to use? The fact that Node is limited is a problem of its own. Of course you can use other things together on the machine, you can use different processes, although it has simple scenario and has complicated scenario because it would be forced to solve a deficiency of Node. It doesn’t mean there’ll be waste, it depends on how you use it. I will not talk to change language, but it is what I would do :) They are two different things. Of course it depends a little on the case, it may not need all that. There is no absolute answer to these things. So it’s not simple to answer that.

  • And in the case of the following: Let’s say I want to create a server for a game like the one I bought (example: CS 1.6), then I go on the site and so on and so on the server for myself to host... let’s say I go host 3 servers (3 different ports) all on the same PC (because each server runs a different map). So, when running these 3 servers at the same time, will q PC make the automatic parelism with other Threads ? or will run everything in the same thread ?

  • 2

    No, computers just do what software tells them to do.

  • Tlgd, I thought the Operating System had some "smart" function of playing a process to another Thread in case q a Main Thread was "crowded"

  • 1

    It is not your program that will directly manage the use of the nucleus, usually who manages it is the operating system itself, as necessary, outside that on a server will not only have a running program, an operating system is a composed of several programs, many already running, the processor will not only serve you, will serve to everything running.

1 answer

1


Node.js has the module cluster, which allows you to start Worker processes that split requests on the same port. In practice, you start a number of processes equal to the number of colors of your processor and make the most of each one. Source: https://nodejs.org/docs/latest/api/cluster.html

  • 1

    Man, it was like that ! VLW

Browser other questions tagged

You are not signed in. Login or sign up in order to post.