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

Node clustering with websockets

I have a node cluster where the master responds to http requests. The server also listens to websocket connections (via socket.io). A client connects to the server via the said websocket. Now the client choses between various games (with each node…
InsOp
  • 2,425
  • 3
  • 27
  • 42
5
votes
1 answer

node.js + socket.io: auction website development

I am currently working on an auction script using node.js and socket.io.But site was developed by using PHP & MySQL. Here I'm using node.js + socket.io for auction bidding process only. The site will have 500-1000 logged in users viewing a single…
4
votes
2 answers

Unable to create node script cluster with PM2

I am trying to create node script cluster with PM2 but getting errors and its not working Main node script in typescript import express from 'express'; import mongoose from 'mongoose'; const app = express(); app.get('/', (req, res) => { const…
PHP Connect
  • 539
  • 2
  • 7
  • 24
4
votes
1 answer

NodeJS Express - Send specific routes to specific cluster workers?

I have a central API server starting cluster worker instances. Each instance has a specific bigger job, and there might be manipulations I want to do on that specific instance only. This was the rough idea I had in mind: API Server with express,…
Tiago
  • 1,984
  • 1
  • 21
  • 43
4
votes
2 answers

NodeJS cluster, Is it really needed?

I decided that i want to investigate what is the best possible way to handle big amount of traffic with NodeJS server, i did a small test on 2 digital ocean servers which has 1GB RAM / 2 CPUs No-Cluster server code: // Include Express var express =…
Roy Hershko
  • 123
  • 5
4
votes
2 answers

Issue with Cluster on Visual studio code (F5) on Node.js v6.0.0

I have some issue with Visual studio code with Cluster Edit If I hit Ctrl + F5 it works correctly, what it's doing other than just F5, do I need to start command always with Ctrl? --- It seems like workers never starts when started with VS Code…
EspeH
  • 1,308
  • 2
  • 16
  • 34
3
votes
0 answers

PM2 not using Round Robin for Node Clusters on Windows

Hi everyone i have recently started to dive into clusters on Node and i'm having an issue with PM2, this is the code i'm trying to run using clusters (server.js): const express = require('express'); const cluster = require('cluster'); const os =…
3
votes
0 answers

NodeJS Clustering with Database connections

I have the question exactly as this one: Nodejs Cluster with MySQL connections I want to know what is the recommended approach to create database connections for nodejs clusters - either create one database connection to be shared across all…
3
votes
2 answers

Is it possible to use Node worker threads to perform database inserts?

I recently read about Node's "worker_threads" module that allows parallel execution of Javascript code in multiple threads which is useful for CPU-intensive operations. (NOTE: these are not web workers made by Chrome in the browser) I'm building a…
3
votes
2 answers

Node cluster have multiple processes listen to the same port

I was reading about clusters in Node js i came across with a simple example, whereas the main file creates four childs processes and each of them listens to 8080 port. The code runs well but i dont get: How its possible to have multiple child…
George Paouris
  • 525
  • 4
  • 16
3
votes
1 answer

Node.js Cluster for Multiple WebSocket Clients Connecting to Different WebSocket Servers?

I am using Node.js to implement a Websocket client that subscribes to datafeed from multiple Websocket servers. foo = new WebSocket('ws://foo.host ...') bar = new WebSocket('ws://barhost ...') baz = new WebSocket('ws://baz.host ...') qux = new…
Nyxynyx
  • 61,411
  • 155
  • 482
  • 830
3
votes
0 answers

How to separate heartbeat to its own thread for RabbitMQ connection

I have a process that uses RabbitMQ and NodeJS to do image processing. Due to the intensive task, I think I have the same issue as the link here https://github.com/squaremo/amqp.node/issues/261 I am trying to figure out how to implement the last…
Crash667
  • 343
  • 2
  • 16
3
votes
1 answer

Node.js Cluster architecture: how to scale master worker

I have build a Node.js built-in cluster architecture with master/worker configuration. The application is using express to serve api and static files and it is deployed with Docker: [D O C K E R: 8080] --- N ---> [W O R K E R: 3001 ] --- 1 ---> [M…
loretoparisi
  • 15,724
  • 11
  • 102
  • 146
3
votes
0 answers

How to configure Node.js PM2 to distribute work evenly among workers?

I have a situation where I create a Node.js cluster using PM2. A single request fired at a worker would take considerable time (2+ mins) as it's doing intensive computations (in a pipeline of steps) with a couple of I/O operations at different…
Ahmed Moawad
  • 351
  • 4
  • 13
3
votes
1 answer

How can I share one resource across Node clusters

I am using node cluster module, and each worker loads a database connection. index.js const cluster = require('cluster'); const database = require('./db.js'); if (cluster.isMaster) { cluster.fork(); cluster.fork(); } else {...} db.js const…
d-_-b
  • 21,536
  • 40
  • 150
  • 256
1
2
3
11 12