I have set up a NodeJS cluster with socket.io like documentation suggests.
On one of the workers, I have emitter that is supposed to emit to all clients in a loop. Everything works fine until I start using namespaces. When emitting to a namespace,…
Right now I am struggling with debugging of NodeJs application which is clustered and is running on Docker. Found on this link and this information in it:
Remember, Node.js is still single-threaded in most cases, so even on a
single server you’ll…
I need help on clusters in node. This is he skeleton of the program
global values a,b,c
function1{
get data from websocket and update the value a,b,c for every incoming message from datastream.
}
function2{
while(1){
do some…
So I've written the below code into a MyScript.js file; (Taken directly from node.js docs at https://nodejs.org/api/cluster.html)
const cluster = require('cluster');
const http = require('http');
const numCPUs =…
I have added clustering to my express.js app, and I've specified 2 workers, in the app I connect to my db via mongoose, but when I run the app, my my mongoose connection (mongoose.connect) runs twice. I have tried putting it in the master cluster,…
I use cluster and have 2 nodes that were running. each node has one API that was doing a task for around 5-6 seconds.
For example
in cluster.js
const cluster = require("cluster");
if (cluster.isMaster) {
for (let i = 0; i < 2; i++) {
…
I am building a browsergame. The prototype is done and now i am thinking of how i can scale and host it. I already have a "gameserver", which currently handles one gamesession. A game session consists of a socketio connection to 8 players (max).
I…
Im using pm2 to manage concurrent requests to my API, so far so good, I've managed to make it work.
My api has only one route. Each request takes between 1-2 min to completely resolve and send back the response. As soon as I make my first request, I…
From Node.JS docs:
These child Nodes are still whole new instances of V8. Assume at least 30ms startup and 10mb memory for each new Node. That is, you cannot create many thousands of them.
Conclusion the best thing to do is to fork just as the…
My server receives a list base64 image eg [img1,img2....] at an endpoint.
I have function getPoses(img) that takes an image and returns an object back.
I want to be able to map the images to getPoses() and get the object back for each image in…
Trying to understand how nodejs works in terms of cpu memory usage we have 4 instances in prod that are slowing down because of heavy lifting and we have load balancer in place.
would it make sense to add node-cluster at instance/app level so we…
I'm wondering (since there's no mention of this in the official documentation) if there's a way to emit events from the worker processes which have a different event name from the default, which is message, so that I can set up listeners in the…
I am trying to run a Node.js cluster within my Express app, but only for one specific function.
My app is a standard Express app generated with the express app generator.
My app initially scrapes an eCommerce website to get a list of categories in…
So I'm trying to implement forking all express requests to setup different uid per fork.
My current approach I just setup euid and restore it after a request like this:
const mainUID = process.geteuid();
app.get('/', () => {
…
I'm running a Nodejs Express server in a clustered environment.
The server gets hundreds of requests for the same resource.
While processing the request for this resource, I make an async call to another service(say service A), wait for its…