Questions tagged [node-cluster]

a Node.js module for multi-core network serving.

Cluster is a Node.js module for multi-core network serving.

https://nodejs.org/api/cluster.html

173 questions
0
votes
1 answer

NodeJS Cluster with socket.io namespaces issue

I have set up a NodeJS cluster with socket.io like documentation suggests. On one of the workers, I have emitter that is supposed to emit to all clients in a loop. Everything works fine until I start using namespaces. When emitting to a namespace,…
Dmitry
  • 23
  • 1
  • 5
0
votes
1 answer

Does it make sense to cluster NodeJs (in order to take advantage of multiple CPUs) if will be deployed with orchestration tool like Kubernetes?

Right now I am struggling with debugging of NodeJs application which is clustered and is running on Docker. Found on this link and this information in it: Remember, Node.js is still single-threaded in most cases, so even on a single server you’ll…
Juraj Zovinec
  • 226
  • 1
  • 15
0
votes
0 answers

multithreading/clusters in node.js,

I need help on clusters in node. This is he skeleton of the program global values a,b,c function1{ get data from websocket and update the value a,b,c for every incoming message from datastream. } function2{ while(1){ do some…
0
votes
1 answer

Node.js Clusters - why is the script running multiple times with no obvious reason?

So I've written the below code into a MyScript.js file; (Taken directly from node.js docs at https://nodejs.org/api/cluster.html) const cluster = require('cluster'); const http = require('http'); const numCPUs =…
joedotnot
  • 4,810
  • 8
  • 59
  • 91
0
votes
1 answer

Mongoose duplicate connections in a clustered express.js app

I have added clustering to my express.js app, and I've specified 2 workers, in the app I connect to my db via mongoose, but when I run the app, my my mongoose connection (mongoose.connect) runs twice. I have tried putting it in the master cluster,…
0
votes
0 answers

Node.js Cluster load balancing in endpoint level

I use cluster and have 2 nodes that were running. each node has one API that was doing a task for around 5-6 seconds. For example in cluster.js const cluster = require("cluster"); if (cluster.isMaster) { for (let i = 0; i < 2; i++) { …
0
votes
1 answer

NodeJs-Cluster with Socket.IO and Namespaces

I am building a browsergame. The prototype is done and now i am thinking of how i can scale and host it. I already have a "gameserver", which currently handles one gamesession. A game session consists of a socketio connection to 8 players (max). I…
mick
  • 127
  • 2
  • 11
0
votes
2 answers

Node clusters with pm2 queues every other request

Im using pm2 to manage concurrent requests to my API, so far so good, I've managed to make it work. My api has only one route. Each request takes between 1-2 min to completely resolve and send back the response. As soon as I make my first request, I…
Omar Omeiri
  • 1,506
  • 1
  • 17
  • 33
0
votes
1 answer

Node create processes as the number of cores

From Node.JS docs: These child Nodes are still whole new instances of V8. Assume at least 30ms startup and 10mb memory for each new Node. That is, you cannot create many thousands of them. Conclusion the best thing to do is to fork just as the…
George Paouris
  • 525
  • 4
  • 16
0
votes
0 answers

NodeJS using Cluster to run a function in parallel

My server receives a list base64 image eg [img1,img2....] at an endpoint. I have function getPoses(img) that takes an image and returns an object back. I want to be able to map the images to getPoses() and get the object back for each image in…
0
votes
1 answer

Does nodejs Master process utilize all the cpu memory?

Trying to understand how nodejs works in terms of cpu memory usage we have 4 instances in prod that are slowing down because of heavy lifting and we have load balancer in place. would it make sense to add node-cluster at instance/app level so we…
hussain
  • 6,587
  • 18
  • 79
  • 152
0
votes
1 answer

Is it possible to name events differently from "message" in the NodeJS cluster module?

I'm wondering (since there's no mention of this in the official documentation) if there's a way to emit events from the worker processes which have a different event name from the default, which is message, so that I can set up listeners in the…
Milan Velebit
  • 1,933
  • 2
  • 15
  • 32
0
votes
2 answers

Node.js cluster for only a specific function within an Express app

I am trying to run a Node.js cluster within my Express app, but only for one specific function. My app is a standard Express app generated with the express app generator. My app initially scrapes an eCommerce website to get a list of categories in…
joshua miller
  • 1,686
  • 1
  • 13
  • 22
0
votes
0 answers

Run each express request in new fork

So I'm trying to implement forking all express requests to setup different uid per fork. My current approach I just setup euid and restore it after a request like this: const mainUID = process.geteuid(); app.get('/', () => { …
xercool
  • 883
  • 1
  • 8
  • 24
0
votes
1 answer

Nodejs- prevent concurrent async calls on clustered server

I'm running a Nodejs Express server in a clustered environment. The server gets hundreds of requests for the same resource. While processing the request for this resource, I make an async call to another service(say service A), wait for its…
user3638992
  • 87
  • 2
  • 9