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
3
votes
1 answer

NodeJS Agenda scheduler: cluster with 2 or 3 workers, jobs are not getting "distributed" evenly

I'm using the great NodeJS Agenda task scheduler (https://github.com/agenda/agenda) to schedule background jobs in my Node/Express app. Agenda can also run in a Node Cluster configuration, however I'm running into a problem with that (maybe I…
leo
  • 1,175
  • 12
  • 13
3
votes
1 answer

PM2 Cluster Mode vs. Node Cluster Performance

I understand that PM2 Cluster Mode allows us to easily scale across CPUs on a single machine. Does it create multiple instances of the node application it is scaling? Essentially, is it the same thing as running multiple node applications on…
Nick
  • 4,002
  • 4
  • 30
  • 41
3
votes
3 answers

nodejs - How should i use nginx along with pm2 for my application running in cluster mode?

I have given a task to use nginx and pm2 in my application. How should i use nginx infront of my nodejs application which is running using pm2 in cluster mode? Also learned that pm2 itself provides built-in load balancer, why should i use nginx…
VJohn
  • 493
  • 1
  • 14
  • 23
3
votes
1 answer

How to send private message (emit) from socket.io-redis

I am developing a real time application using Node.js, Socket,io, Redis. I try to send a private message to one client from worker, but it does not work. Array io.sockets.connected on worker is empty and i can't refer to the client. Code on…
3
votes
1 answer

Node.js Clustering- Forking, how much memory is actually used?

http://stackabuse.com/setting-up-a-node-js-cluster/ says " To be clear, forking in Node is very different than a POISIX fork in that it doesn't actually clone the current process, but it does start up a new V8 instance. Although this is one of the…
Arman
  • 2,665
  • 3
  • 14
  • 19
3
votes
1 answer

NodeJS Cluster how share object array across workers

So I have setup a simple nodejs cluster game, I am new to nodejs. basically players connect to to my worker using socket.io then they get created to a Player Object then added to my PlayerManager.LIST array. Now this causes me some issues as the…
user2716281
  • 155
  • 3
  • 11
3
votes
1 answer

cannot debug node child process (using node native debugger)

I'm trying to debug node child process, using native node debugger. See this repo for example. I tried all king of options, according to: debug1, debug1, debug3 (and a lot of other references I found online). Non of those options worked for…
Yaniv Efraim
  • 6,633
  • 7
  • 53
  • 96
3
votes
1 answer

Node.js cluster - optimal number of workers

I have 4 cores and ran this code according to this example : var cluster = require('cluster'); var http = require('http'); var numCPUs = require('os').cpus().length; var id = 0; if (cluster.isWorker) { id = cluster.worker.id; } var iterations…
zbeyens
  • 321
  • 1
  • 5
  • 16
3
votes
1 answer

Node.js Cluster

I am writing an application in Node.js which serves dynamic web pages. I would like this application to scale over multiple CPU cores, so I have decided to use cluster to create a worker for each CPU core. I also use a 3rd party API which needs to…
user2248702
  • 2,741
  • 7
  • 41
  • 69
3
votes
0 answers

How to run socketio server properly on multiple cores using cluster module of NodeJS?

Socket IO server is running fine on single instance of NodeJs. But when I'm using cluster module of NodeJS to run the servers on multiple cores I'm getting the error, "Connection closed before receiving a handshake response". I've googled the reason…
Bharat Kul Ratan
  • 985
  • 2
  • 12
  • 24
3
votes
1 answer

distinguish node master cluster in other modules

I am working on a node project which I want to run it via node cluster. As I have some shared resources and configuration which can be used by each node cluster(Worker), At the start up I read these configuration and save it into redis db. In…
ali
  • 1,023
  • 2
  • 14
  • 38
2
votes
1 answer

How to share cache between nodejs clusters?

I have been using the nestjs CacheModule along with cache-manager-redis-store as a cache store in an API. Recently I started clustering the app using node's cluster module. But now it seems like each cluster has it's own separate cache. Is it…
mismaah
  • 344
  • 5
  • 21
2
votes
0 answers

PM2 cluster mode vs nginx load balancing (single host)?

We are in the process of investigating response issues of our, express based, node.js (10.x) app, since customers are indicating our API endpoints don’t always respond in a timely manner and sometimes they get 504s. Since this first started with an…
Andre M
  • 6,649
  • 7
  • 52
  • 93
2
votes
2 answers

Unable to get all workers in worker block while using cluster in NodeJS

I need to get all workers id list in worker block. Here is my example which is not working const cluster = require('cluster'); var a = []; if (cluster.isMaster) { console.log('I am master'); cluster.fork(); cluster.fork(); } else if…
Arif Khan
  • 5,039
  • 2
  • 16
  • 27
2
votes
0 answers

Caching posts using redis

I have a forum which contains groups, new groups are created all the time by users, currently I'm using node-cache with ttl to cache groups and it's content (posts, likes and comments). The server worked great at the begging but the performance…
Rawhi
  • 6,155
  • 8
  • 36
  • 57
1 2
3
11 12