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

Issue with node cluster (nodejs)

i went through this code (sample of node-cluster), its working fine without errors, but no response from http server. as per logs it was created workers and those are running var cluster = require('cluster') , http = require('http'); var server…
Ganesh Kumar
  • 1,341
  • 11
  • 18
0
votes
0 answers

TypeScript types by using Node multiprocessing are falsly assumed undefined

Using TypeScript to write a multiprocessing Node application I see the problem that e.g. this code is creating a compiler error although it's definitely working: // main.ts import * as child from 'child_process'; child.fork('my_fork.js', [],…
Chris
  • 3,265
  • 5
  • 37
  • 50
0
votes
0 answers

Which approach is used by PM2 to run the application in cluster mode?

PM2 uses the node cluster module to run the application cluster mode. The cluster module supports two methods of distributing incoming connections. The first one (and the default one on all platforms except Windows) is the round-robin approach,…
Bennison J
  • 414
  • 1
  • 12
0
votes
0 answers

How does PM2 manages the cluster when PM2 run the application in the cluster mode?

I explored that PM2 uses the node cluster module to run the application in cluster, node cluster module follows two approches to handle the cluster. uses the round-robin approach by default for handling cluster. Document for how the node cluster…
Bennison J
  • 414
  • 1
  • 12
0
votes
1 answer

How can a forked node process send data to a terminal or to the parent on exit?

I am dealing with an odd problem which I couldn't find the answer to online, nor through a lot of trial and error. In a multi-multi process cluster, forked worker processes can run arbitrarily long commands, but the parent process listens for…
0
votes
0 answers

Use singleton classes with cluster module in nodejs

I want to use cluster module in my node application. I am also using Prometheus in my application. In the documentation, I read that with the cluster module a new process is spawned. Will it also create a new instance of cached node modules?…
Akshit Bansal
  • 75
  • 1
  • 7
0
votes
1 answer

Node.js on multi-core machines for file I/O operations

I'm a bit confused because all the examples I read about Node cluster module only seem to apply to webservers and concurrent requests. Otherwise to CPU intensive application it is recommended to use the worker_threads module. And what about I/O file…
João Pimentel Ferreira
  • 14,289
  • 10
  • 80
  • 109
0
votes
0 answers

how to integrate cluster in a correct way to a nodejs express server and a mongodb connection?

I am creating a resp api with nodejs express and babael using escma6 my question is the following I have a module where I have the connection to the database and the configuration and another file called server where I create the server with…
0
votes
0 answers

Node cluster worker is undefined when ran in docker container

I have a simple node setup using node cluster that forks worker processes. When I run it directly using node index.js everything works just fine. However, when I create a docker container and try to run in from there, I get an error saying cannot…
0
votes
0 answers

TypeError on socket.io adapter

For using multiple nodes in my socket.io as part of expanding I used the Redis socket.io adapter @socket.io/redis-adapter. The transmission of data/messages between sockets on different nodes works fine on the cluster mode. When trying to fetch the…
0
votes
1 answer

Worker threads vs node cluster for server application with internal data exchange

I understand that questions like this can be a matter of opinion, which is why I tried to provide more details. I'm developing a WebSocket server app with the following 'features': 2-3 connections can point to the same User Users can occasionally…
user64675
  • 482
  • 7
  • 25
0
votes
0 answers

I'm Creating Worker with node Cluster module now, I need to set load balance

My question is, now that I need a load balancer something else, or this Worker that I create according to the CPUs Core size works perfectly well in the node app. const express = require("express"); const cluster = require("cluster"); const…
Smit Gajera
  • 1,001
  • 1
  • 8
  • 26
0
votes
1 answer

node.js cluster module not helping how I thought it would

I recently learned about the cluster module in node, and wanted to give it a spin. I have a super basic express app that look like this. const express = require('express'); const app = express(); const cluster = require('cluster'); const os =…
Chaim Friedman
  • 6,124
  • 4
  • 33
  • 61
0
votes
2 answers

pm2 constantly leaking memory when running app in cluster mode

Currently, running my prod apps in cluster mode with pm2 to create multiple instances. But over time, I can see increase in memory usage. How to solve it as for ow I need to restart the app manually? pm2 start app.js -i 0 -o "/dev/null"
devil
  • 19
  • 4
0
votes
1 answer

How to make a worker thread answer an express request?

I have a simple express app that on request launches a worker, the worker generates a lot of data (5 MB, takes about 3 seconds) and sends over the first 50KB of it. Incase the same request is repeated, the worker gets a message to send over the next…
Puasfeq
  • 33
  • 2