0

Suppose I have a 16 core machine and I want a Node.js webserver to use 8 cores, and I want a Java REST/API server to use the other 8. The idea being that Node would be making API calls over localhost, even though the API server may handle requests coming from elsewhere.

I'm using Node's cluster module to accomplish this; basically, doing cluster.fork() 8x. I assume Java has its own ways of utilizing X cores, but others are writing that piece of software.

Is there anything I need to do, from a node perspective, to ensure that my code doesn't run on any of the same cores Java is running on? It seems simple enough to run fork() n/2 times, where n = numCpus, and if that's all I need to worry about, great, but I wanted to ask this question to make sure I'm not missing something important.

2
  • in node.js you can fork n/2 times. But bigger problem will be to identify which n/2 cores you used in nodejs from java if at all the same is possible via java. :) Commented Oct 3, 2014 at 17:33
  • Running fork() will spawn a new process, yes, but there is no feasible way to keep a process on a core without using some sort of virtualization. Commented Oct 3, 2014 at 17:59

1 Answer 1

1

It is up the the kernel scheduler to manage this, but you can potentially give the kernel some hints by setting the processor affinity. For example, on linux, you might be able to use taskset to set process affinity for each of the started processes.

Sign up to request clarification or add additional context in comments.

2 Comments

I see. Thanks. Do you have a sense of whether processor affinity hinting is something routinely done for multi-process software deployments, or is it more of a last resort kind of thing? I'm inclined at this point not to use it unless things don't seem to be working properly.
(Marking this as accepted since "processor affinity" was really the term I was looking for and opens up a lot more google search results.)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.