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
1
vote
0 answers

How is the new connection being distributed across the instances when PM2 uses the round-robin for cluster?

Recently, I have been exploring the concept, How the PM2 works in cluster mode. assume that, that we have four instances that are running in the cluster mode. and consider instance ids are 13, 14, 15, 16 By default PM2 uses the node cluster module…
Bennison J
  • 414
  • 1
  • 12
1
vote
0 answers

Differences between Node.js Thread Pool and Clustering Node.js

Recently I've been researching about Node.js core architecture, but still I don't understand some concepts. So assume that I have 6 core CPU and it's an Intel CPU, so actually I have 12 logical processors for threads for any execution in my computer…
1
vote
0 answers

Server not starting when called by a cluster fork with import

I'm tryng to make a server with muitiple workers, but the server never starts when I use the import statment. If i put the code directly inside the worker function they run with no problems. code with import: import os from 'os' import cluster from…
1
vote
1 answer

End all worker threads after the first one ends in Node.js

I am currently trying to find a way to end all worker threads spawned from some master thread after any of them finishes. I've looked at various schemes for communication between worker threads (e.g. cluster.worker.send(), process.send(), etc.), but…
1
vote
0 answers

How send data from child nodes to the Master node and get a response back

Currently I'm doing a nodejs project where I don't want to use any third party packages or database systems. Now I'm almost done with the project. But here's the problem. I've some authentication related functionality that needs "Sticky Load…
h-sifat
  • 1,455
  • 3
  • 19
1
vote
1 answer

Why Websocket/ws is connecting socket on single core? (Nodejs/Cluster)

I am running node js and using cluster module. In child process I am creating a websocket server and on websocket connection I am doing console.log(process.pid) on each websocket connection. I even added a loop in worker thread to slow it down which…
1
vote
0 answers

Node server connection event firing but request event not firing

I am working on a chat app where the master node is receiving request through tcp socket and after analyzing if its normal http request or web socket it is passing the socket to worker node. I see that when the socket is not read(i.e the…
1
vote
0 answers

I am working on a chat app with socket.io and cluster node with all incoming sockets to be handled by particular node instance(required for app need)

In my master node, a tcp socket is intercepting all requests, where I want to separate normal http requests and websocket ones. I need the wobsocket connections to be handled by a particular node in a time (say worker 5 handles all connections until…
1
vote
0 answers

Does nock work with nodes multi threaded Cluster module?

I have an application which uses NodeJs Cluster module to fork multiple processes of the app, each of these process send out post request to an endpoint which i want to nock. Now i understand that nock works by overwriting the nodes process…
1
vote
1 answer

Socket.io-redis gives error when added as adapter to Socket.io instance

Im experimenting abit with Socket.io and Socket.Io-redis. I have my Redis server up and running. The error i get when starting the Socket.Io server is: ReplyError: ERR unknown command 'pubsub' I dont know why i get this error at all. The Redis…
Knut
  • 11
  • 2
1
vote
1 answer

Node.js CPU Load balancing Websocket Client over Multiple CPU Cores

My node.js app currently subscribes to a number of websocket servers that is starting to push a lot of data over to the app every second. This websocket client app has several event handlers that does some work upon receiving the websocket…
Nyxynyx
  • 61,411
  • 155
  • 482
  • 830
1
vote
2 answers

Why is the "Hello world" printed 2 times?

Why dose the program print "Hello World" 2 times rather than only 1 time? The console.log is excuted before cluster.fork(). import * as cluster from "cluster"; console.log("Hello World"); if (cluster.isMaster) { const worker = cluster.fork(); …
HongyanShen
  • 1,435
  • 2
  • 14
  • 23
1
vote
1 answer

Is it a good practice to start http server on one port for Cluster forks for 1-3k requests per second?

Is it a good way to create a high loaded server on node.js? I need to start the high loaded (1-3k requests) http server to handle Post requests. As a backend i chosen node.js with express. I have created one shared http server for all forked…
the_man
  • 77
  • 1
  • 7
1
vote
0 answers

Event sequence in node cluster

In node cluster docs there are few events that is called by cluster. Out of which 'online' and 'listening' is two events that I am confused about which is being called first. there is a line written The difference between 'fork' and 'online' is…
RateM
  • 241
  • 1
  • 4
  • 15
1
vote
0 answers

Knex does not seam to wait for sqlite to become freed

I recently implemented Node cluster as a way to vertically scale my application. Since it uses multiple threads now I naturally added stress tests to the application and that revealed an issue with my application. So for the sake of this question I…
Rouz
  • 1,247
  • 2
  • 15
  • 37