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

How to know when all cluster workers are up?

I am looking to bootstrap a node cluster with a start and stop methods. I wanted to write something similar to: myCluster.start().then(()=>{ return myCluster.stop().then(()=>{console.log('smooth stop!…
Tiago Bértolo
  • 3,874
  • 3
  • 35
  • 53
0
votes
1 answer

Node cluster; only one process being used

I'm running a clustered node app, with 8 worker processes. I'm giving output when serving requests, and the output includes the ID of the process which handled the request: app.get('/some-url', function(req, res) { console.log('Request being…
Gershom Maes
  • 7,358
  • 2
  • 35
  • 55
0
votes
1 answer

What is the best solution for caching in clustered Node Js application?

I used cluster-node-cache with following code. var obj = { my: "Special", variable: 42 }; cache.set("myKey", obj).then(function(result) { console.log(result.err); console.log(result.success); …
Lokinder Singh Chauhan
  • 2,326
  • 1
  • 20
  • 23
0
votes
1 answer

Mongoose connection error with cluster

I'm having an issue with node.js/cluster and mongoose connection. I'm not sure I can connect multiple fork of my web server on the same db using mongoose, is it ? There is a snippet of my code: const express = require('express'); const app =…
Liroo Pierre
  • 875
  • 2
  • 9
  • 25
0
votes
2 answers

NodeJS + Cluster + Socket.IO how to create game room properly?

I'm making a simple game engine, which implements room manipulation. I was thinking a lot and still have doubts that I'm making rooms not in the valid way. Here's the scenario. 1) There's one static room, where users are able to 'register'. 2) after…
Nika
  • 1,864
  • 3
  • 23
  • 44
0
votes
1 answer

Socket.io not working with node cluster

I have a cluster.js with the following code: var numOfCpus = 16; var cluster = require('cluster'); if (cluster.isMaster) { for (var i = 0; i < numOfCpus; i++) { cluster.fork(); } console.log("master is running"); } else { …
Kshitij Mittal
  • 2,698
  • 3
  • 25
  • 40
0
votes
1 answer

Node using all processors without clustering. How come?

I have a nodejs application that gets data from one server and pushes into another. For testing I sent 1000 requests to my node server and saw what happens on the system monitor. There I could see that all 4 processors were 100% occupied. Now, from…
harsh atal
  • 411
  • 6
  • 16
0
votes
2 answers

How to end all workers from master in NodeJS?

I need to end all workers if my db fails to connect... if (cluster.isMaster) { mongoose.connect(config.db.path, function(err) { if (err) { logger.error('Can\'t connect to database') // kill all workers here …
Kin
  • 4,466
  • 13
  • 54
  • 106
0
votes
1 answer

Node Cluster is not dispatching task to another worker available

This is my first question of Stack-overflow so please pardon me for any mistake or insufficient information in this question. So, I am trying to use cluster module of nodeJS for my server and I run nodeJS through my windows machine. I know nodeJS…
Tarun Garg
  • 126
  • 8
0
votes
2 answers

Is there a way to send a message from a worker to other workers in node.js?

I can use process.send to send a message from a worker to a master. I can use the following code to send a message from the master to each worker. for (var id in cluster.workers) { cluster.workers[id].send({command: 'doSomething'}); } To send a…
rohithpr
  • 6,050
  • 8
  • 36
  • 60
0
votes
1 answer

Node Cluster issue using Socket.io and Redis

Ok, I have an express-powered API where I also have socket.io running to receive/send realtime events...all works just dandy. I need to cluster my app. I set everything up based on the below code. I spin up workers, they get connections and…
Rob Bennet
  • 477
  • 1
  • 9
  • 21
0
votes
1 answer

RxJS and Master/Worker workflow

Now my program which uses cluster lib looks like this: if(cluster.isMaster) { // here goes Rx subscriptions and workflows for the Master } else if (cluster.isWorker){ // here goes Rx subscriptions and workflows for a Worker } It's looks a little…
kharandziuk
  • 12,020
  • 17
  • 63
  • 121
0
votes
1 answer

Load testing node.js app on Amazon EC2 instance

I am trying to load test my node.js application with endpoint as API hosted on an m4.large instance using JMeter with 1 master and 3 slaves. The 'server.js' file uses clustering in node.js as follows: var C_NUM_CPU = 2; // Listen for dying…
0
votes
1 answer

Node with Cluster vs Node with Threads a gogo

What are the main differences between node cluster and Threads agogo and what are the advantages or disadvantages of each? As far as I have understood threads a agogo creates a thread to run in the background and node cluster creates a new process…
Coder3000
  • 130
  • 7
0
votes
0 answers

zmq node js cluster

I am going in circles with following problem, I want to segregate my zmq related code into separate module, I have started my express app in cluster, something like below in my www.js file if (cluster.isMaster) { for (; i < cpuLength; i++) { …
Kamal
  • 1,122
  • 11
  • 18
1 2 3
11
12